rustc_middle::ty::context

Struct TyCtxtFeed

source
pub struct TyCtxtFeed<'tcx, KEY: Copy> {
    pub tcx: TyCtxt<'tcx>,
    key: KEY,
}
Expand description

This struct should only be created by create_def.

Fields§

§tcx: TyCtxt<'tcx>§key: KEY

Implementations§

source§

impl<'tcx, KEY: Copy> TyCtxtFeed<'tcx, KEY>

source

pub fn key(&self) -> KEY

source

pub fn downgrade(self) -> Feed<'tcx, KEY>

source§

impl<'tcx> TyCtxtFeed<'tcx, LocalDefId>

source

pub fn def_id(&self) -> LocalDefId

source

pub fn feed_owner_id(&self) -> TyCtxtFeed<'tcx, OwnerId>

source

pub fn feed_hir(&self)

source§

impl<'tcx, K: IntoQueryParam<LocalDefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn local_def_id_to_hir_id(self, value: ProvidedValue<'tcx>)

Returns HIR ID for the given LocalDefId.

source§

impl<'tcx, K: IntoQueryParam<LocalDefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn opt_hir_owner_nodes(self, value: ProvidedValue<'tcx>)

Gives access to the HIR nodes and bodies inside key if it’s a HIR owner.

This can be conveniently accessed by methods on tcx.hir(). Avoid calling this query directly.

source§

impl<'tcx, K: IntoQueryParam<OwnerId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn hir_attrs(self, value: ProvidedValue<'tcx>)

Gives access to the HIR attributes inside the HIR owner key.

This can be conveniently accessed by methods on tcx.hir(). Avoid calling this query directly.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn type_of(self, value: ProvidedValue<'tcx>)

Returns the Ty of the given DefId. If the DefId points to an alias, it will “skip” this alias to return the aliased type.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn is_type_alias_impl_trait(self, value: ProvidedValue<'tcx>)

[query description - consider adding a doc-comment!] determine whether the opaque is a type-alias impl trait

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn generics_of(self, value: ProvidedValue<'tcx>)

Maps from the DefId of an item (trait/struct/enum/fn) to its associated generics.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn predicates_of(self, value: ProvidedValue<'tcx>)

Maps from the DefId of an item (trait/struct/enum/fn) to the predicates (where-clauses) that must be proven true in order to reference it. This is almost always the “predicates query” that you want.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn explicit_item_bounds(self, value: ProvidedValue<'tcx>)

Returns the list of bounds that are required to be satisfied by a implementation or definition. For associated types, these must be satisfied for an implementation to be well-formed, and for opaque types, these are required to be satisfied by the hidden-type of the opaque.

Syntactially, these are the bounds written on the trait’s type definition, or those after the impl keyword for an opaque:

type X: Bound + 'lt
//      ^^^^^^^^^^^
impl Debug + Display
//   ^^^^^^^^^^^^^^^

key is the DefId of the associated type or opaque type.

Bounds from the parent (e.g. with nested impl trait) are not included.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn explicit_item_super_predicates(self, value: ProvidedValue<'tcx>)

The set of item bounds (see TyCtxt::explicit_item_bounds) that share the Self type of the item. These are a subset of the bounds that may explicitly be used for things like closure signature deduction.

source§

impl<'tcx, K: IntoQueryParam<LocalDefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn mir_built(self, value: ProvidedValue<'tcx>)

Build the MIR for a given DefId and prepare it for const qualification.

See the rustc dev guide for more info.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn explicit_predicates_of(self, value: ProvidedValue<'tcx>)

Returns the predicates written explicitly by the user.

You should probably use predicates_of unless you’re looking for predicates with explicit spans for diagnostics purposes.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn inferred_outlives_of(self, value: ProvidedValue<'tcx>)

Returns the inferred outlives predicates (e.g., for struct Foo<'a, T> { x: &'a T }, this would return T: 'a).

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn constness(self, value: ProvidedValue<'tcx>)

Returns true if this is a const fn, use the is_const_fn to know whether your crate actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might not have the feature gate active).

Do not call this function manually. It is only meant to cache the base data for the is_const_fn function. Consider using is_const_fn or is_const_fn_raw instead.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn coroutine_kind(self, value: ProvidedValue<'tcx>)

Returns Some(coroutine_kind) if the node pointed to by def_id is a coroutine.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn associated_item(self, value: ProvidedValue<'tcx>)

Maps from a trait/impl item to the trait/impl item “descriptor”.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn eval_static_initializer(self, value: ProvidedValue<'tcx>)

Evaluate a static’s initializer, returning the allocation of the initializer’s memory.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn def_kind(self, value: ProvidedValue<'tcx>)

[query description - consider adding a doc-comment!] looking up definition kind of tcx.def_path_str(def_id)

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn def_span(self, value: ProvidedValue<'tcx>)

Gets the span for the definition.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn def_ident_span(self, value: ProvidedValue<'tcx>)

Gets the span for the identifier of the definition.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn codegen_fn_attrs(self, value: ProvidedValue<'tcx>)

[query description - consider adding a doc-comment!] computing codegen attributes of tcx.def_path_str(def_id)

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn param_env(self, value: ProvidedValue<'tcx>)

Gets the ParameterEnvironment for a given item; this environment will be in “user-facing” mode, meaning that it is suitable for type-checking etc, and it does not normalize specializable associated types. This is almost always what you want, unless you are doing MIR optimizations, in which case you might want to use reveal_all() method to change modes.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn defaultness(self, value: ProvidedValue<'tcx>)

Returns whether the impl or associated function has the default keyword.

source§

impl<'tcx, K: IntoQueryParam<DefId> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn visibility(self, value: ProvidedValue<'tcx>)

Computes the visibility of the provided def_id.

If the item from the def_id doesn’t have a visibility, it will panic. For example a generic type parameter will panic if you call this method on it:

use std::fmt::Debug;

pub trait Foo<T: Debug> {}

In here, if you call visibility on T, it’ll panic.

source§

impl<'tcx, K: IntoQueryParam<CrateNum> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn crate_name(self, value: ProvidedValue<'tcx>)

Gets the name of the crate.

source§

impl<'tcx, K: IntoQueryParam<()> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn output_filenames(self, value: ProvidedValue<'tcx>)

Return the filenames where output artefacts shall be stored.

This query returns an &Arc because codegen backends need the value even after the TyCtxt has been destroyed.

source§

impl<'tcx, K: IntoQueryParam<()> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn features_query(self, value: ProvidedValue<'tcx>)

[query description - consider adding a doc-comment!] looking up enabled feature gates

source§

impl<'tcx, K: IntoQueryParam<()> + Copy> TyCtxtFeed<'tcx, K>

source

pub fn crate_for_resolver(self, value: ProvidedValue<'tcx>)

[query description - consider adding a doc-comment!] the ast before macro expansion and name resolution

Trait Implementations§

source§

impl<'tcx, KEY: Clone + Copy> Clone for TyCtxtFeed<'tcx, KEY>

source§

fn clone(&self) -> TyCtxtFeed<'tcx, KEY>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<'tcx, KEY: Copy + Copy> Copy for TyCtxtFeed<'tcx, KEY>

source§

impl<KEY: Copy, CTX> !HashStable<CTX> for TyCtxtFeed<'_, KEY>

Never return a Feed from a query. Only queries that create a DefId are allowed to feed queries for that DefId.

Auto Trait Implementations§

§

impl<'tcx, KEY> Freeze for TyCtxtFeed<'tcx, KEY>
where KEY: Freeze,

§

impl<'tcx, KEY> !RefUnwindSafe for TyCtxtFeed<'tcx, KEY>

§

impl<'tcx, KEY> !Send for TyCtxtFeed<'tcx, KEY>

§

impl<'tcx, KEY> !Sync for TyCtxtFeed<'tcx, KEY>

§

impl<'tcx, KEY> Unpin for TyCtxtFeed<'tcx, KEY>
where KEY: Unpin,

§

impl<'tcx, KEY> !UnwindSafe for TyCtxtFeed<'tcx, KEY>

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<'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, dst: *mut T)

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

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> 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 = 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>,

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<Tcx, T> Value<Tcx> for T
where Tcx: DepContext,

source§

default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T

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: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.