Skip to main content

PassCtx

Struct PassCtx 

Source
pub(crate) struct PassCtx<'sess> {
    session: &'sess Session,
    body_mir_opt_level: usize,
}

Fields§

§session: &'sess Session

Prefer Self::mir_opt_level to Session::mir_opt_level to account for overrides.

§body_mir_opt_level: usize

The MIR optimization level for this body; may be overridden by #[optimize].

Implementations§

Source§

impl<'sess> PassCtx<'sess>

Source

pub(crate) fn for_body(tcx: TyCtxt<'sess>, def_id: DefId) -> Self

Source

pub(crate) fn mir_opt_level(&self) -> usize

The effective MIR optimization level for this body, including #[optimize] overrides.

Methods from Deref<Target = 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

pub fn gather_enabled_denied_partial_mitigations( &self, ) -> Vec<DeniedPartialMitigation>

Source

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

Source

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

Source

pub fn finish_diagnostics(&self) -> 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>

feature must be a language feature.

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 proc_macro_quoted_spans(&self) -> impl Iterator<Item = (usize, Span)>

Source

pub fn save_proc_macro_span(&self, span: Span) -> usize

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 coverage_options(&self) -> &CoverageOptions

Provides direct access to the CoverageOptions struct, so that individual flags for debugging/testing coverage instrumetation don’t need separate accessors.

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_arity_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 target_filesearch(&self) -> &FileSearch

Source

pub fn host_filesearch(&self) -> &FileSearch

Source

pub fn wasm_proc_macro_filesearch(&self) -> &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 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_visibility(&self) -> SymbolVisibility

Returns the default symbol visibility.

Source

pub fn staticlib_components(&self, verbatim: bool) -> (&str, &str)

Source

pub fn lint_groups_iter(&self) -> Box<dyn Iterator<Item = LintGroup> + '_>

Source

pub fn resolve_path( &self, path: impl Into<PathBuf>, span: Span, ) -> Result<PathBuf, Diag<'_>>

Resolves a path mentioned inside Rust code, returning an absolute path.

This unifies the logic used for resolving include_*! and debugger visualizers.

Source

pub fn verbose_internals(&self) -> bool

Source

pub fn print_llvm_stats(&self) -> bool

Source

pub fn print_llvm_stats_json(&self) -> Option<&String>

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 contract_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 dwarf_version(&self) -> u32

Returns the DWARF version passed on the CLI or the default for the target.

Source

pub fn stack_protector(&self) -> StackProtector

Source

pub fn branch_protection(&self) -> Option<BranchProtection>

Returns the -Zbranch-protection info. Note that it is adjusted to the current target, e.g. some targets only support certain Pointer Authentication Code keys.

Accessing the session’s unstable branch_protection option fields directly is linted against.

Source

pub fn must_emit_unwind_tables(&self) -> bool

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 apple_deployment_target(&self) -> OSVersion

Get the deployment target on Apple platforms based on the standard environment variables, or fall back to the minimum version supported by rustc.

This should be guarded behind if sess.target.is_like_darwin.

Source

pub fn sanitizers(&self) -> SanitizerSet

Source

pub fn pointer_authentication(&self) -> bool

Source

pub fn pointer_authentication_functions(&self) -> Option<&PointerAuthSchema>

Source

pub fn pointer_authentication_init_fini(&self) -> Option<&PointerAuthSchema>

Trait Implementations§

Source§

impl<'sess> Clone for PassCtx<'sess>

Source§

fn clone(&self) -> PassCtx<'sess>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'sess> Copy for PassCtx<'sess>

Source§

impl Deref for PassCtx<'_>

Source§

type Target = Session

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'sess> !RefUnwindSafe for PassCtx<'sess>

§

impl<'sess> !Send for PassCtx<'sess>

§

impl<'sess> !Sync for PassCtx<'sess>

§

impl<'sess> !UnwindSafe for PassCtx<'sess>

§

impl<'sess> DynSend for PassCtx<'sess>

§

impl<'sess> DynSync for PassCtx<'sess>

§

impl<'sess> Freeze for PassCtx<'sess>

§

impl<'sess> Unpin for PassCtx<'sess>

§

impl<'sess> UnsafeUnpin for PassCtx<'sess>

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<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for T
where T: Copy,

Source§

fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut T

Source§

fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'tcx mut [T]

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<_>>()).

Source§

type Output = R

Source§

impl<T> DynClone for T
where T: Clone,

Source§

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

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<K> IntoQueryKey<K> for K

Source§

fn into_query_key(self) -> K

Argument conversion from Self to K. This should always be a very cheap conversion, e.g. LocalDefId::to_def_id.
Source§

impl<T> MaybeResult<T> for T

Source§

type Error = !

Source§

fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

Source§

fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

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