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 crate_disambiguator: OnceCell<CrateDisambiguator>,
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: RealFileNameThe 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).
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.
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: CguReuseTrackerUsed for incremental compilation tests. Will only be populated if
-Zquery-dep-graph is specified.
prof: SelfProfilerRefUsed by -Z self-profile.
perf_stats: PerfStatsSome measurements that are being gathered during compilation.
code_stats: CodeStatsData about code being compiled, gathered during compilation.
print_fuel_crate: Option<String>If -zprint-fuel=crate, Some(crate).
print_fuel: AtomicU64Always set to zero and incremented so that we can print fuel expended by a crate.
jobserver: ClientLoaded 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
Invoked all the way at the end to finish off diagnostics printing.
pub fn struct_span_warn_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
msg: &str,
code: DiagnosticId
) -> DiagnosticBuilder<'_>pub fn struct_span_allow<S: Into<MultiSpan>>(
&self,
sp: S,
msg: &str
) -> DiagnosticBuilder<'_>pub fn struct_span_err_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
msg: &str,
code: DiagnosticId
) -> DiagnosticBuilder<'_>pub fn struct_span_fatal<S: Into<MultiSpan>>(
&self,
sp: S,
msg: &str
) -> DiagnosticBuilder<'_>pub fn struct_span_fatal_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
msg: &str,
code: DiagnosticId
) -> DiagnosticBuilder<'_>pub fn span_fatal_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
msg: &str,
code: DiagnosticId
) -> !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.
pub fn diag_span_note_once<'a, 'b>(
&'a self,
diag_builder: &'b mut DiagnosticBuilder<'a>,
msg_id: DiagnosticMessageId,
span: Span,
message: &str
)pub fn diag_note_once<'a, 'b>(
&'a self,
diag_builder: &'b mut DiagnosticBuilder<'a>,
msg_id: DiagnosticMessageId,
message: &str
)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.
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.
Check whether this compile session and crate type use static crt.
Returns the symbol name for the registrar function,
given the crate Svh and the function DefIndex.
pub fn init_incr_comp_session(
&self,
session_dir: PathBuf,
lock_file: Lock,
load_dep_graph: 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.
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
Returns true if we cannot skip the PLT for shared library calls.
Checks if LLVM lifetime markers should be emitted.
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.)
Auto Trait Implementations
impl !RefUnwindSafe for Sessionimpl !UnwindSafe for Session