Struct rustc_ap_rustc_session::Session[][src]

pub struct Session {
Show fields pub target: Target, 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: RealFileName, pub one_time_diagnostics: Lock<FxHashSet<(DiagnosticMessageId, Option<Span>, String)>>, pub stable_crate_id: OnceCell<StableCrateId>, pub recursion_limit: OnceCell<Limit>, pub move_size_limit: OnceCell<usize>, pub type_length_limit: OnceCell<Limit>, pub const_eval_limit: OnceCell<Limit>, pub cgu_reuse_tracker: CguReuseTracker, pub prof: SelfProfilerRef, pub perf_stats: PerfStats, pub code_stats: CodeStats, 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>, pub asm_arch: Option<InlineAsmArch>, pub target_features: FxHashSet<Symbol>, pub if_let_suggestions: Lock<FxHashSet<Span>>, // some fields omitted
}
Expand description

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

Fields

target: Targethost: 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: RealFileName

The directory the compiler has been executed in

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

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.

recursion_limit: OnceCell<Limit>

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

move_size_limit: OnceCell<usize>

The size at which the large_assignments lint starts being emitted.

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.

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.

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.

asm_arch: Option<InlineAsmArch>

Architecture to use for interpreting asm!.

target_features: FxHashSet<Symbol>

Set of enabled features for the current target.

if_let_suggestions: Lock<FxHashSet<Span>>

Spans for if conditions that we have suggested turning into if let.

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]

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

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

pub fn local_stable_crate_id(&self) -> StableCrateId[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 move_size_limit(&self) -> usize[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_allow<S: Into<MultiSpan>>(
    &self,
    sp: S,
    msg: &str
) -> DiagnosticBuilder<'_>
[src]

pub fn struct_allow(&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 emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>)[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 delay_span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: &str)[src]

Delay a span_bug() call until abort_if_errors()

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

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: &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]

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 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 print_llvm_passes(&self) -> bool[src]

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

pub fn mir_opt_level(&self) -> usize[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 init_lint_store(&self, lint_store: Lrc<dyn SessionLintStore>)[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 is_nightly_build(&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 is_wasi_reactor(&self) -> bool[src]

pub fn split_debuginfo(&self) -> SplitDebuginfo[src]

pub fn target_can_use_split_dwarf(&self) -> bool[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,
    stable_crate_id: StableCrateId
) -> 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,
    stable_crate_id: StableCrateId
) -> String
[src]

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

pub fn host_filesearch(&self, kind: PathKind) -> FileSearch<'_>[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 rust_2021(&self) -> bool[src]

Are we allowed to use features from the Rust 2021 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 instrument_coverage(&self) -> bool[src]

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

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

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.

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

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

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

fn in_current_span(self) -> Instrumented<Self>[src]

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

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Error = !

pub fn from(Result<T, <T as MaybeResult<T>>::Error>) -> T[src]

pub fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

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.

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

Performs the conversion.

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.

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

Performs the conversion.

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

pub fn vzip(self) -> V

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

impl<T> Erased for T[src]