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
sourceimpl Session
impl Session
pub fn miri_unleashed_feature(&self, span: Span, feature_gate: Option<Symbol>)
fn check_miri_unleashed_features(&self)
sourcepub fn finish_diagnostics(&self, registry: &Registry)
pub fn finish_diagnostics(&self, registry: &Registry)
Invoked all the way at the end to finish off diagnostics printing.
fn emit_future_breakage(&self)
pub fn local_stable_crate_id(&self) -> StableCrateId
pub fn crate_types(&self) -> &[CrateType]
pub fn init_crate_types(&self, crate_types: Vec<CrateType>)
pub fn struct_span_warn<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, ()>
pub fn struct_span_warn_with_expectation<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>,
id: LintExpectationId
) -> DiagnosticBuilder<'_, ()>
pub fn struct_span_warn_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>,
code: DiagnosticId
) -> DiagnosticBuilder<'_, ()>
pub fn struct_warn(
&self,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, ()>
pub fn struct_warn_with_expectation(
&self,
msg: impl Into<DiagnosticMessage>,
id: LintExpectationId
) -> DiagnosticBuilder<'_, ()>
pub fn struct_span_allow<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, ()>
pub fn struct_allow(
&self,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, ()>
pub fn struct_expect(
&self,
msg: impl Into<DiagnosticMessage>,
id: LintExpectationId
) -> DiagnosticBuilder<'_, ()>
pub fn struct_span_err<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, ErrorGuaranteed>
pub fn struct_span_err_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>,
code: DiagnosticId
) -> DiagnosticBuilder<'_, ErrorGuaranteed>
pub fn struct_err(
&self,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, ErrorGuaranteed>
pub fn struct_err_with_code(
&self,
msg: impl Into<DiagnosticMessage>,
code: DiagnosticId
) -> DiagnosticBuilder<'_, ErrorGuaranteed>
pub fn struct_warn_with_code(
&self,
msg: impl Into<DiagnosticMessage>,
code: DiagnosticId
) -> DiagnosticBuilder<'_, ()>
pub fn struct_span_fatal<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, !>
pub fn struct_span_fatal_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>,
code: DiagnosticId
) -> DiagnosticBuilder<'_, !>
pub fn struct_fatal(
&self,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, !>
pub fn span_fatal<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>
) -> !
pub fn span_fatal_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>,
code: DiagnosticId
) -> !
pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> !
pub fn span_err_or_warn<S: Into<MultiSpan>>(
&self,
is_warning: bool,
sp: S,
msg: impl Into<DiagnosticMessage>
)
pub fn span_err<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>
) -> ErrorGuaranteed
pub fn span_err_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>,
code: DiagnosticId
)
pub fn err(&self, msg: impl Into<DiagnosticMessage>) -> ErrorGuaranteed
pub fn create_err<'a>(
&'a self,
err: impl SessionDiagnostic<'a>
) -> DiagnosticBuilder<'a, ErrorGuaranteed>
pub fn create_feature_err<'a>(
&'a self,
err: impl SessionDiagnostic<'a>,
feature: Symbol
) -> DiagnosticBuilder<'a, ErrorGuaranteed>
pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed
pub fn create_warning<'a>(
&'a self,
err: impl SessionDiagnostic<'a, ()>
) -> DiagnosticBuilder<'a, ()>
pub fn emit_warning<'a>(&'a self, warning: impl SessionDiagnostic<'a, ()>)
pub fn create_fatal<'a>(
&'a self,
fatal: impl SessionDiagnostic<'a, !>
) -> DiagnosticBuilder<'a, !>
pub fn emit_fatal<'a>(&'a self, fatal: impl SessionDiagnostic<'a, !>) -> !
pub fn err_count(&self) -> usize
pub fn has_errors(&self) -> Option<ErrorGuaranteed>
pub fn has_errors_or_delayed_span_bugs(&self) -> bool
pub fn abort_if_errors(&self)
pub fn compile_status(&self) -> Result<(), ErrorGuaranteed>
pub fn track_errors<F, T>(&self, f: F) -> Result<T, ErrorGuaranteed>where
F: FnOnce() -> T,
pub fn span_warn<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>
)
pub fn span_warn_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>,
code: DiagnosticId
)
pub fn warn(&self, msg: impl Into<DiagnosticMessage>)
sourcepub fn delay_span_bug<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>
) -> ErrorGuaranteed
pub fn delay_span_bug<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>
) -> ErrorGuaranteed
Delay a span_bug() call until abort_if_errors()
sourcepub fn delay_good_path_bug(&self, msg: impl Into<DiagnosticMessage>)
pub fn delay_good_path_bug(&self, msg: impl Into<DiagnosticMessage>)
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.
pub fn note_without_error(&self, msg: impl Into<DiagnosticMessage>)
pub fn span_note_without_error<S: Into<MultiSpan>>(
&self,
sp: S,
msg: impl Into<DiagnosticMessage>
)
pub fn struct_note_without_error(
&self,
msg: impl Into<DiagnosticMessage>
) -> DiagnosticBuilder<'_, ()>
pub fn diagnostic(&self) -> &Handler
pub fn source_map(&self) -> &SourceMap
pub fn time_passes(&self) -> bool
sourcepub fn enable_internal_lints(&self) -> bool
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).
pub fn instrument_coverage(&self) -> bool
pub fn instrument_coverage_except_unused_generics(&self) -> bool
pub fn instrument_coverage_except_unused_functions(&self) -> bool
sourcepub fn features_untracked(&self) -> &Features
pub fn features_untracked(&self) -> &Features
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)
pub fn is_sanitizer_cfi_enabled(&self) -> bool
sourcepub fn crt_static(&self, crate_type: Option<CrateType>) -> bool
pub fn crt_static(&self, crate_type: Option<CrateType>) -> bool
Check whether this compile session and crate type use static crt.
pub fn is_wasi_reactor(&self) -> bool
sourcepub fn target_can_use_split_dwarf(&self) -> bool
pub fn target_can_use_split_dwarf(&self) -> bool
Returns true
if the target can use the current split debuginfo configuration.
pub fn generate_proc_macro_decls_symbol(
&self,
stable_crate_id: StableCrateId
) -> String
pub fn target_filesearch(&self, kind: PathKind) -> FileSearch<'_>
pub fn host_filesearch(&self, kind: PathKind) -> FileSearch<'_>
sourcepub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf>
pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf>
Returns a list of directories where target-specific tool binaries are located.
pub fn init_incr_comp_session(
&self,
session_dir: PathBuf,
lock_file: Lock,
load_dep_graph: bool
)
pub fn finalize_incr_comp_session(&self, new_directory_path: PathBuf)
pub fn mark_incr_comp_session_as_invalid(&self)
pub fn incr_comp_session_dir(&self) -> Ref<'_, PathBuf>
pub fn incr_comp_session_dir_opt(&self) -> Option<Ref<'_, PathBuf>>
pub fn print_perf_stats(&self)
sourcepub fn consider_optimizing<T: Fn() -> String>(
&self,
crate_name: &str,
msg: T
) -> bool
pub fn consider_optimizing<T: Fn() -> String>(
&self,
crate_name: &str,
msg: T
) -> 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.
pub fn rust_2015(&self) -> bool
sourcepub fn needs_plt(&self) -> bool
pub fn needs_plt(&self) -> bool
Returns true
if we cannot skip the PLT for shared library calls.
sourcepub fn emit_lifetime_markers(&self) -> bool
pub fn emit_lifetime_markers(&self) -> bool
Checks if LLVM lifetime markers should be emitted.
pub fn is_proc_macro_attr(&self, attr: &Attribute) -> bool
pub fn contains_name(&self, attrs: &[Attribute], name: Symbol) -> bool
pub fn find_by_name<'a>(
&'a self,
attrs: &'a [Attribute],
name: Symbol
) -> Option<&'a Attribute>
pub fn filter_by_name<'a>(
&'a self,
attrs: &'a [Attribute],
name: Symbol
) -> impl Iterator<Item = &'a Attribute>
pub fn first_attr_value_str_by_name(
&self,
attrs: &[Attribute],
name: Symbol
) -> Option<Symbol>
sourceimpl Session
impl Session
pub fn verbose(&self) -> bool
pub fn instrument_mcount(&self) -> bool
pub fn time_llvm_passes(&self) -> bool
pub fn meta_stats(&self) -> bool
pub fn asm_comments(&self) -> bool
pub fn verify_llvm_ir(&self) -> bool
pub fn print_llvm_passes(&self) -> bool
pub fn binary_dep_depinfo(&self) -> bool
pub fn mir_opt_level(&self) -> usize
sourcepub fn panic_strategy(&self) -> PanicStrategy
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.
pub fn fewer_names(&self) -> bool
pub fn unstable_options(&self) -> bool
pub fn is_nightly_build(&self) -> bool
pub fn overflow_checks(&self) -> bool
pub fn relocation_model(&self) -> RelocModel
pub fn code_model(&self) -> Option<CodeModel>
pub fn tls_model(&self) -> TlsModel
pub fn split_debuginfo(&self) -> SplitDebuginfo
pub fn stack_protector(&self) -> StackProtector
pub fn must_emit_unwind_tables(&self) -> bool
sourcepub fn threads(&self) -> usize
pub fn threads(&self) -> usize
Returns the number of query threads that should be used for this compilation
sourcepub fn codegen_units(&self) -> usize
pub fn codegen_units(&self) -> usize
Returns the number of codegen units that should be used for this compilation
pub fn teach(&self, code: &DiagnosticId) -> bool
pub fn edition(&self) -> Edition
pub fn link_dead_code(&self) -> bool
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut 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: 6032 bytes