Struct rustc_session::Session

source ·
pub struct Session {
Show 25 fields pub target: Target, pub host: Target, pub opts: Options, pub host_tlib_path: Lrc<SearchPath>, pub target_tlib_path: Lrc<SearchPath>, pub parse_sess: ParseSess, pub sysroot: PathBuf, pub local_crate_source_file: Option<PathBuf>, crate_types: OnceCell<Vec<CrateType>>, pub stable_crate_id: OnceCell<StableCrateId>, features: OnceCell<Features>, incr_comp_session: OneThread<RefCell<IncrCompSession>>, pub cgu_reuse_tracker: CguReuseTracker, pub prof: SelfProfilerRef, pub perf_stats: PerfStats, pub code_stats: CodeStats, optimization_fuel: Lock<OptimizationFuel>, pub print_fuel: AtomicU64, pub jobserver: Client, pub driver_lint_caps: FxHashMap<LintId, Level>, pub ctfe_backtrace: Lock<CtfeBacktrace>, miri_unleashed_features: Lock<Vec<(Span, Option<Symbol>)>>, pub asm_arch: Option<InlineAsmArch>, pub target_features: FxHashSet<Symbol>, pub unstable_target_features: FxHashSet<Symbol>,
}
Expand description

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

Fields§

§target: Target§host: Target§opts: Options§host_tlib_path: Lrc<SearchPath>§target_tlib_path: Lrc<SearchPath>§parse_sess: ParseSess§sysroot: PathBuf§local_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.

§crate_types: OnceCell<Vec<CrateType>>§stable_crate_id: OnceCell<StableCrateId>

The stable_crate_id is constructed out of the crate name and all the -C metadata arguments passed to the compiler. Its value 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>§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: Lock<OptimizationFuel>

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

§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.

§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. The Lock is only used by miri to allow setting ctfe_backtrace after analysis when MIRI_BACKTRACE is set. This makes it only apply to miri’s errors and not to all CTFE errors.

§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.

§asm_arch: Option<InlineAsmArch>

Architecture to use for interpreting asm!.

§target_features: FxHashSet<Symbol>

Set of enabled features for the current target.

§unstable_target_features: FxHashSet<Symbol>

Set of enabled features for the current target, including unstable ones.

Implementations§

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

Delay a span_bug() call until abort_if_errors()

Used for code paths of expensive computations that should only take place when warnings or errors are emitted. If no messages are emitted (“good path”), then it’s likely a bug.

Returns true if internal lints should be added to the lint store - i.e. if -Zunstable-options is provided and this isn’t rustdoc (internal lints can trigger errors to be emitted under rustdoc).

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.

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

Returns true if the target can use the current split debuginfo configuration.

Returns a list of directories where target-specific tool binaries are located.

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.

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

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

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

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

Checks if LLVM lifetime markers should be emitted.

Calculates the flavor of LTO to use for this compilation.

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.

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

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

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 6520 bytes