Struct rustc_session::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 psess: ParseSess, pub sysroot: PathBuf, pub io: CompilerIO, incr_comp_session: RwLock<IncrCompSession>, pub prof: SelfProfilerRef, pub code_stats: CodeStats, optimization_fuel: Lock<OptimizationFuel>, pub print_fuel: AtomicU64, pub jobserver: Client, pub lint_store: Option<Lrc<dyn LintStoreMarker>>, pub registered_lints: bool, 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: FxIndexSet<Symbol>, pub unstable_target_features: FxIndexSet<Symbol>, pub cfg_version: &'static str, pub using_internal_features: Arc<AtomicBool>, pub expanded_args: Vec<String>,
}
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>§psess: ParseSess§sysroot: PathBuf§io: CompilerIO

Input, input file path and output file path to this compilation process.

§incr_comp_session: RwLock<IncrCompSession>§prof: SelfProfilerRef

Used by -Z self-profile.

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

§lint_store: Option<Lrc<dyn LintStoreMarker>>

This only ever stores a LintStore but we don’t want a dependency on that type here.

§registered_lints: bool

Should be set if any lints are registered in lint_store.

§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: FxIndexSet<Symbol>

Set of enabled features for the current target.

§unstable_target_features: FxIndexSet<Symbol>

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

§cfg_version: &'static str

The version of the rustc process, possibly including a commit hash and description.

§using_internal_features: Arc<AtomicBool>

The inner atomic value is set to true when a feature marked as internal is enabled. Makes it so that “please report a bug” is hidden, as ICEs with internal features are wontfix, and they are usually the cause of the ICEs. None signifies that this is not tracked.

§expanded_args: Vec<String>

All commandline args used to invoke the compiler, with @file args fully expanded. This will only be used within debug info, e.g. in the pdb file on windows This is mainly useful for other tools that reads that debuginfo to figure out how to call the compiler with the same arguments.

Implementations§

source§

impl Session

source

pub fn timer(&self, what: &'static str) -> VerboseTimingGuard<'_>

source

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

Used by -Z self-profile.

source§

impl Session

source

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

source

pub fn local_crate_source_file(&self) -> Option<RealFileName>

source

fn check_miri_unleashed_features(&self) -> Option<ErrorGuaranteed>

source

pub fn finish_diagnostics(&self, registry: &Registry) -> Option<ErrorGuaranteed>

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

source

pub fn is_test_crate(&self) -> bool

Returns true if the crate is a testing one.

source

pub fn create_feature_err<'a>( &'a self, err: impl Diagnostic<'a>, feature: Symbol, ) -> Diag<'a>

source

pub fn record_trimmed_def_paths(&self)

Record the fact that we called trimmed_def_paths, and do some checking about whether its cost was justified.

source

pub fn dcx(&self) -> DiagCtxtHandle<'_>

source

pub fn source_map(&self) -> &SourceMap

source

pub fn enable_internal_lints(&self) -> bool

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

source

pub fn instrument_coverage(&self) -> bool

source

pub fn instrument_coverage_branch(&self) -> bool

source

pub fn instrument_coverage_condition(&self) -> bool

source

pub fn instrument_coverage_mcdc(&self) -> bool

source

pub fn coverage_no_mir_spans(&self) -> bool

True if -Zcoverage-options=no-mir-spans was passed.

source

pub fn is_sanitizer_cfi_enabled(&self) -> bool

source

pub fn is_sanitizer_cfi_canonical_jump_tables_disabled(&self) -> bool

source

pub fn is_sanitizer_cfi_canonical_jump_tables_enabled(&self) -> bool

source

pub fn is_sanitizer_cfi_generalize_pointers_enabled(&self) -> bool

source

pub fn is_sanitizer_cfi_normalize_integers_enabled(&self) -> bool

source

pub fn is_sanitizer_kcfi_enabled(&self) -> bool

source

pub fn is_split_lto_unit_enabled(&self) -> bool

source

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

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

source

pub fn is_wasi_reactor(&self) -> bool

source

pub fn target_can_use_split_dwarf(&self) -> bool

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

source

pub fn generate_proc_macro_decls_symbol( &self, stable_crate_id: StableCrateId, ) -> String

source

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

source

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

source

pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf>

Returns a list of directories where target-specific tool binaries are located. Some fallback directories are also returned, for example if --sysroot is used but tools are missing (#125246): we also add the bin directories to the sysroot where rustc is located.

source

pub fn init_incr_comp_session(&self, session_dir: PathBuf, lock_file: Lock)

source

pub fn finalize_incr_comp_session(&self, new_directory_path: PathBuf)

source

pub fn mark_incr_comp_session_as_invalid(&self)

source

pub fn incr_comp_session_dir(&self) -> MappedReadGuard<'_, PathBuf>

source

pub fn incr_comp_session_dir_opt(&self) -> Option<MappedReadGuard<'_, PathBuf>>

source

pub fn consider_optimizing( &self, get_crate_name: impl Fn() -> Symbol, msg: impl Fn() -> String, ) -> bool

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.

source

pub fn is_rust_2015(&self) -> bool

Is this edition 2015?

source

pub fn at_least_rust_2018(&self) -> bool

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

source

pub fn at_least_rust_2021(&self) -> bool

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

source

pub fn at_least_rust_2024(&self) -> bool

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

source

pub fn needs_plt(&self) -> bool

Returns true if we should use the PLT for shared library calls.

source

pub fn emit_lifetime_markers(&self) -> bool

Checks if LLVM lifetime markers should be emitted.

source

pub fn diagnostic_width(&self) -> usize

source

pub fn default_hidden_visibility(&self) -> bool

Whether the default visibility of symbols should be “hidden” rather than “default”.

source§

impl Session

source

pub fn verbose_internals(&self) -> bool

source

pub fn print_llvm_stats(&self) -> bool

source

pub fn verify_llvm_ir(&self) -> bool

source

pub fn binary_dep_depinfo(&self) -> bool

source

pub fn mir_opt_level(&self) -> usize

source

pub fn lto(&self) -> Lto

Calculates the flavor of LTO to use for this compilation.

source

pub fn panic_strategy(&self) -> PanicStrategy

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.

source

pub fn fewer_names(&self) -> bool

source

pub fn unstable_options(&self) -> bool

source

pub fn is_nightly_build(&self) -> bool

source

pub fn overflow_checks(&self) -> bool

source

pub fn ub_checks(&self) -> bool

source

pub fn relocation_model(&self) -> RelocModel

source

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

source

pub fn tls_model(&self) -> TlsModel

source

pub fn direct_access_external_data(&self) -> Option<bool>

source

pub fn split_debuginfo(&self) -> SplitDebuginfo

source

pub fn stack_protector(&self) -> StackProtector

source

pub fn must_emit_unwind_tables(&self) -> bool

source

pub fn threads(&self) -> usize

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

source

pub fn codegen_units(&self) -> CodegenUnits

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

source

pub fn teach(&self, code: ErrCode) -> bool

source

pub fn edition(&self) -> Edition

source

pub fn filename_display_preference( &self, scope: RemapPathScopeComponents, ) -> FileNameDisplayPreference

Auto Trait Implementations§

§

impl !Freeze for Session

§

impl !RefUnwindSafe for Session

§

impl !Send for Session

§

impl !Sync for Session

§

impl Unpin for Session

§

impl !UnwindSafe for Session

Blanket Implementations§

source§

impl<T> Aligned for T

source§

const ALIGN: Alignment = _

Alignment of Self.
source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, R> CollectAndApply<T, R> for T

source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

source§

impl<T> Filterable for T

source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

source§

fn upcast(self, interner: I) -> U

source§

impl<I, T> UpcastFrom<I, T> for T

source§

fn upcast_from(from: T, _tcx: I) -> T

source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<'a, T> Captures<'a> for T
where T: ?Sized,

source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T

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: 6464 bytes