[][src]Struct rustc_session::session::Session

pub struct Session {
    pub target: Config,
    pub host: Target,
    pub opts: Options,
    pub host_tlib_path: SearchPath,
    pub target_tlib_path: Option<SearchPath>,
    pub parse_sess: ParseSess,
    pub sysroot: PathBuf,
    pub local_crate_source_file: Option<PathBuf>,
    pub working_dir: (PathBuf, bool),
    pub one_time_diagnostics: Lock<FxHashSet<(DiagnosticMessageId, Option<Span>, String)>>,
    crate_types: OnceCell<Vec<CrateType>>,
    pub crate_disambiguator: OnceCell<CrateDisambiguator>,
    features: OnceCell<Features>,
    pub recursion_limit: OnceCell<Limit>,
    pub type_length_limit: OnceCell<Limit>,
    pub const_eval_limit: OnceCell<Limit>,
    incr_comp_session: OneThread<RefCell<IncrCompSession>>,
    pub cgu_reuse_tracker: CguReuseTracker,
    pub prof: SelfProfilerRef,
    pub perf_stats: PerfStats,
    pub code_stats: CodeStats,
    optimization_fuel_crate: Option<String>,
    optimization_fuel: Lock<OptimizationFuel>,
    pub print_fuel_crate: Option<String>,
    pub print_fuel: AtomicU64,
    pub jobserver: Client,
    pub driver_lint_caps: FxHashMap<LintId, Level>,
    pub trait_methods_not_found: Lock<FxHashSet<Span>>,
    pub confused_type_with_std_module: Lock<FxHashMap<Span, Span>>,
    pub system_library_path: OneThread<RefCell<Option<Option<PathBuf>>>>,
    pub ctfe_backtrace: Lock<CtfeBacktrace>,
    miri_unleashed_features: Lock<Vec<(Span, Option<Symbol>)>>,
    pub real_rust_source_base_dir: Option<PathBuf>,
    pub asm_arch: Option<InlineAsmArch>,
    pub target_features: FxHashSet<Symbol>,
    known_attrs: Lock<MarkedAttrs>,
    used_attrs: Lock<MarkedAttrs>,
}

Represents the data associated with a compilation session for a single crate.

Fields

target: Confighost: Targetopts: Optionshost_tlib_path: SearchPathtarget_tlib_path: Option<SearchPath>

None if the host and target are the same.

parse_sess: ParseSesssysroot: PathBuflocal_crate_source_file: Option<PathBuf>

The name of the root source file of the crate, in the local file system. None means that there is no source file.

working_dir: (PathBuf, bool)

The directory the compiler has been executed in plus a flag indicating if the value stored here has been affected by path remapping.

one_time_diagnostics: Lock<FxHashSet<(DiagnosticMessageId, Option<Span>, String)>>

Set of (DiagnosticId, Option<Span>, message) tuples tracking (sub)diagnostics that have been set once, but should not be set again, in order to avoid redundantly verbose output (Issue #24690, #44953).

crate_types: OnceCell<Vec<CrateType>>crate_disambiguator: OnceCell<CrateDisambiguator>

The crate_disambiguator is constructed out of all the -C metadata arguments passed to the compiler. Its value together with the crate-name forms a unique global identifier for the crate. It is used to allow multiple crates with the same name to coexist. See the rustc_codegen_llvm::back::symbol_names module for more information.

features: OnceCell<Features>recursion_limit: OnceCell<Limit>

The maximum recursion limit for potentially infinitely recursive operations such as auto-dereference and monomorphization.

type_length_limit: OnceCell<Limit>

The maximum length of types during monomorphization.

const_eval_limit: OnceCell<Limit>

The maximum blocks a const expression can evaluate.

incr_comp_session: OneThread<RefCell<IncrCompSession>>cgu_reuse_tracker: CguReuseTracker

Used for incremental compilation tests. Will only be populated if -Zquery-dep-graph is specified.

prof: SelfProfilerRef

Used by -Z self-profile.

perf_stats: PerfStats

Some measurements that are being gathered during compilation.

code_stats: CodeStats

Data about code being compiled, gathered during compilation.

optimization_fuel_crate: Option<String>

If -zfuel=crate=n is specified, Some(crate).

optimization_fuel: Lock<OptimizationFuel>

Tracks fuel info if -zfuel=crate=n is specified.

print_fuel_crate: Option<String>

If -zprint-fuel=crate, Some(crate).

print_fuel: AtomicU64

Always set to zero and incremented so that we can print fuel expended by a crate.

jobserver: Client

Loaded up early on in the initialization of this Session to avoid false positives about a job server in our environment.

driver_lint_caps: FxHashMap<LintId, Level>

Cap lint level specified by a driver specifically.

trait_methods_not_found: Lock<FxHashSet<Span>>

Spans of trait methods that weren't found to avoid emitting object safety errors

confused_type_with_std_module: Lock<FxHashMap<Span, Span>>

Mapping from ident span to path span for paths that don't exist as written, but that exist under std. For example, wrote str::from_utf8 instead of std::str::from_utf8.

system_library_path: OneThread<RefCell<Option<Option<PathBuf>>>>

Path for libraries that will take preference over libraries shipped by Rust. Used by windows-gnu targets to priortize system mingw-w64 libraries.

ctfe_backtrace: Lock<CtfeBacktrace>

Tracks the current behavior of the CTFE engine when an error occurs. Options range from returning the error without a backtrace to returning an error and immediately printing the backtrace to stderr.

miri_unleashed_features: Lock<Vec<(Span, Option<Symbol>)>>

This tracks where -Zunleash-the-miri-inside-of-you was used to get around a const check, optionally with the relevant feature gate. We use this to warn about unleashing, but with a single diagnostic instead of dozens that drown everything else in noise.

real_rust_source_base_dir: Option<PathBuf>

Base directory containing the src/ for the Rust standard library, and potentially rustc as well, if we can can find it. Right now it's always $sysroot/lib/rustlib/src/rust (i.e. the rustup rust-src component).

This directory is what the virtual /rustc/$hash is translated back to, if Rust was built with path remapping to /rustc/$hash enabled (the rust.remap-debuginfo option in config.toml).

asm_arch: Option<InlineAsmArch>

Architecture to use for interpreting asm!.

target_features: FxHashSet<Symbol>

Set of enabled features for the current target.

known_attrs: Lock<MarkedAttrs>used_attrs: Lock<MarkedAttrs>

Implementations

impl Session[src]

pub fn timer<'a>(&'a self, what: &'static str) -> VerboseTimingGuard<'a>[src]

pub fn time<R>(&self, what: &'static str, f: impl FnOnce() -> R) -> R[src]

impl Session[src]

pub fn miri_unleashed_feature(&self, span: Span, feature_gate: Option<Symbol>)[src]

fn check_miri_unleashed_features(&self)[src]

pub fn finish_diagnostics(&self, registry: &Registry)[src]

Invoked all the way at the end to finish off diagnostics printing.

pub fn local_crate_disambiguator(&self) -> CrateDisambiguator[src]

pub fn crate_types(&self) -> &[CrateType][src]

pub fn init_crate_types(&self, crate_types: Vec<CrateType>)[src]

pub fn recursion_limit(&self) -> Limit[src]

pub fn type_length_limit(&self) -> Limit[src]

pub fn const_eval_limit(&self) -> Limit[src]

pub fn struct_span_warn<S: Into<MultiSpan>>(
    &self,
    sp: S,
    msg: &str
) -> DiagnosticBuilder<'_>
[src]

pub fn struct_span_warn_with_code<S: Into<MultiSpan>>(
    &self,
    sp: S,
    msg: &str,
    code: DiagnosticId
) -> DiagnosticBuilder<'_>
[src]

pub fn struct_warn(&self, msg: &str) -> DiagnosticBuilder<'_>[src]

pub fn struct_span_err<S: Into<MultiSpan>>(
    &self,
    sp: S,
    msg: &str
) -> DiagnosticBuilder<'_>
[src]

pub fn struct_span_err_with_code<S: Into<MultiSpan>>(
    &self,
    sp: S,
    msg: &str,
    code: DiagnosticId
) -> DiagnosticBuilder<'_>
[src]

pub fn struct_err(&self, msg: &str) -> DiagnosticBuilder<'_>[src]

pub fn struct_err_with_code(
    &self,
    msg: &str,
    code: DiagnosticId
) -> DiagnosticBuilder<'_>
[src]

pub fn struct_span_fatal<S: Into<MultiSpan>>(
    &self,
    sp: S,
    msg: &str
) -> DiagnosticBuilder<'_>
[src]

pub fn struct_span_fatal_with_code<S: Into<MultiSpan>>(
    &self,
    sp: S,
    msg: &str,
    code: DiagnosticId
) -> DiagnosticBuilder<'_>
[src]

pub fn struct_fatal(&self, msg: &str) -> DiagnosticBuilder<'_>[src]

pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ![src]

pub fn span_fatal_with_code<S: Into<MultiSpan>>(
    &self,
    sp: S,
    msg: &str,
    code: DiagnosticId
) -> !
[src]

pub fn fatal(&self, msg: &str) -> ![src]

pub fn span_err_or_warn<S: Into<MultiSpan>>(
    &self,
    is_warning: bool,
    sp: S,
    msg: &str
)
[src]

pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: &str)[src]

pub fn span_err_with_code<S: Into<MultiSpan>>(
    &self,
    sp: S,
    msg: &str,
    code: DiagnosticId
)
[src]

pub fn err(&self, msg: &str)[src]

pub fn err_count(&self) -> usize[src]

pub fn has_errors(&self) -> bool[src]

pub fn has_errors_or_delayed_span_bugs(&self) -> bool[src]

pub fn abort_if_errors(&self)[src]

pub fn compile_status(&self) -> Result<(), ErrorReported>[src]

pub fn track_errors<F, T>(&self, f: F) -> Result<T, ErrorReported> where
    F: FnOnce() -> T, 
[src]

pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: &str)[src]

pub fn span_warn_with_code<S: Into<MultiSpan>>(
    &self,
    sp: S,
    msg: &str,
    code: DiagnosticId
)
[src]

pub fn warn(&self, msg: &str)[src]

pub fn opt_span_warn<S: Into<MultiSpan>>(&self, opt_sp: Option<S>, msg: &str)[src]

pub fn delay_span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: &str)[src]

Delay a span_bug() call until abort_if_errors()

pub fn note_without_error(&self, msg: &str)[src]

pub fn span_note_without_error<S: Into<MultiSpan>>(&self, sp: S, msg: &str)[src]

pub fn struct_note_without_error(&self, msg: &str) -> DiagnosticBuilder<'_>[src]

pub fn diagnostic(&self) -> &Handler[src]

fn diag_once<'a, 'b>(
    &'a self,
    diag_builder: &'b mut DiagnosticBuilder<'a>,
    method: DiagnosticBuilderMethod,
    msg_id: DiagnosticMessageId,
    message: &str,
    span_maybe: Option<Span>
)
[src]

Analogous to calling methods on the given DiagnosticBuilder, but deduplicates on lint ID, span (if any), and message for this Session

pub fn diag_span_note_once<'a, 'b>(
    &'a self,
    diag_builder: &'b mut DiagnosticBuilder<'a>,
    msg_id: DiagnosticMessageId,
    span: Span,
    message: &str
)
[src]

pub fn diag_note_once<'a, 'b>(
    &'a self,
    diag_builder: &'b mut DiagnosticBuilder<'a>,
    msg_id: DiagnosticMessageId,
    message: &str
)
[src]

pub fn diag_span_suggestion_once<'a, 'b>(
    &'a self,
    diag_builder: &'b mut DiagnosticBuilder<'a>,
    msg_id: DiagnosticMessageId,
    span: Span,
    message: &str,
    suggestion: String
)
[src]

pub fn source_map(&self) -> &SourceMap[src]

pub fn verbose(&self) -> bool[src]

pub fn time_passes(&self) -> bool[src]

pub fn instrument_mcount(&self) -> bool[src]

pub fn time_llvm_passes(&self) -> bool[src]

pub fn meta_stats(&self) -> bool[src]

pub fn asm_comments(&self) -> bool[src]

pub fn verify_llvm_ir(&self) -> bool[src]

pub fn borrowck_stats(&self) -> bool[src]

pub fn print_llvm_passes(&self) -> bool[src]

pub fn binary_dep_depinfo(&self) -> bool[src]

pub fn features_untracked(&self) -> &Features[src]

Gets the features enabled for the current compilation session. DO NOT USE THIS METHOD if there is a TyCtxt available, as it circumvents dependency tracking. Use tcx.features() instead.

pub fn init_features(&self, features: Features)[src]

pub fn lto(&self) -> Lto[src]

Calculates the flavor of LTO to use for this compilation.

pub fn panic_strategy(&self) -> PanicStrategy[src]

Returns the panic strategy for this compile session. If the user explicitly selected one using '-C panic', use that, otherwise use the panic strategy defined by the target.

pub fn fewer_names(&self) -> bool[src]

pub fn unstable_options(&self) -> bool[src]

pub fn overflow_checks(&self) -> bool[src]

pub fn crt_static(&self, crate_type: Option<CrateType>) -> bool[src]

Check whether this compile session and crate type use static crt.

pub fn relocation_model(&self) -> RelocModel[src]

pub fn code_model(&self) -> Option<CodeModel>[src]

pub fn tls_model(&self) -> TlsModel[src]

pub fn must_not_eliminate_frame_pointers(&self) -> bool[src]

pub fn must_emit_unwind_tables(&self) -> bool[src]

pub fn generate_plugin_registrar_symbol(
    &self,
    disambiguator: CrateDisambiguator
) -> String
[src]

Returns the symbol name for the registrar function, given the crate Svh and the function DefIndex.

pub fn generate_proc_macro_decls_symbol(
    &self,
    disambiguator: CrateDisambiguator
) -> String
[src]

pub fn target_filesearch(&self, kind: PathKind) -> FileSearch<'_>[src]

pub fn host_filesearch(&self, kind: PathKind) -> FileSearch<'_>[src]

pub fn set_incr_session_load_dep_graph(&self, load: bool)[src]

pub fn incr_session_load_dep_graph(&self) -> bool[src]

pub fn init_incr_comp_session(
    &self,
    session_dir: PathBuf,
    lock_file: Lock,
    load_dep_graph: bool
)
[src]

pub fn finalize_incr_comp_session(&self, new_directory_path: PathBuf)[src]

pub fn mark_incr_comp_session_as_invalid(&self)[src]

pub fn incr_comp_session_dir(&self) -> Ref<'_, PathBuf>[src]

pub fn incr_comp_session_dir_opt(&self) -> Option<Ref<'_, PathBuf>>[src]

pub fn print_perf_stats(&self)[src]

pub fn consider_optimizing<T: Fn() -> String>(
    &self,
    crate_name: &str,
    msg: T
) -> bool
[src]

We want to know if we're allowed to do an optimization for crate foo from -z fuel=foo=n. This expends fuel if applicable, and records fuel if applicable.

pub fn threads(&self) -> usize[src]

Returns the number of query threads that should be used for this compilation

pub fn codegen_units(&self) -> usize[src]

Returns the number of codegen units that should be used for this compilation

pub fn teach(&self, code: &DiagnosticId) -> bool[src]

pub fn rust_2015(&self) -> bool[src]

pub fn rust_2018(&self) -> bool[src]

Are we allowed to use features from the Rust 2018 edition?

pub fn edition(&self) -> Edition[src]

pub fn needs_plt(&self) -> bool[src]

Returns true if we cannot skip the PLT for shared library calls.

pub fn emit_lifetime_markers(&self) -> bool[src]

Checks if LLVM lifetime markers should be emitted.

pub fn mark_attr_known(&self, attr: &Attribute)[src]

pub fn is_attr_known(&self, attr: &Attribute) -> bool[src]

pub fn mark_attr_used(&self, attr: &Attribute)[src]

pub fn is_attr_used(&self, attr: &Attribute) -> bool[src]

pub fn check_name(&self, attr: &Attribute, name: Symbol) -> bool[src]

Returns true if the attribute's path matches the argument. If it matches, then the attribute is marked as used. Returns true if the attribute's path matches the argument. If it matches, then the attribute is marked as used.

This method should only be used by rustc, other tools can use Attribute::has_name instead, because only rustc is supposed to report the unused_attributes lint. (MetaItem and NestedMetaItem are produced by lowering an Attribute and don't have identity, so they only have the has_name method, and you need to mark the original Attribute as used when necessary.)

pub fn is_proc_macro_attr(&self, attr: &Attribute) -> bool[src]

pub fn contains_name(&self, attrs: &[Attribute], name: Symbol) -> bool[src]

pub fn find_by_name<'a>(
    &'a self,
    attrs: &'a [Attribute],
    name: Symbol
) -> Option<&'a Attribute>
[src]

pub fn filter_by_name<'a>(
    &'a self,
    attrs: &'a [Attribute],
    name: Symbol
) -> impl Iterator<Item = &'a Attribute>
[src]

pub fn first_attr_value_str_by_name(
    &self,
    attrs: &[Attribute],
    name: Symbol
) -> Option<Symbol>
[src]

Auto Trait Implementations

impl !RefUnwindSafe for Session

impl !Send for Session

impl !Sync for Session

impl Unpin for Session

impl !UnwindSafe for Session

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.