TyCtxtFeed in rustc_middle::ty - Rust
Description: This struct should only be created by `create_def`.

Skip to main content

## TyCtxtFeed

# Struct TyCtxtFeed

Source

    pub struct TyCtxtFeed<'tcx, K: Copy> {
        pub tcx: TyCtxt<'tcx>,
        key: K,
    }

Expand description

This struct should only be created by `create_def`.

## Fields§

§`tcx: TyCtxt<'tcx>`§`key: K`

## Implementations§

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

[query description - consider adding a doc-comment!] getting owner for `tcx.def_path_str(def_id)`

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

[query description - consider adding a doc-comment!] getting child of lowered delayed AST owner `tcx.def_path_str(def_id)`

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

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

This can be conveniently accessed by `tcx.hir_*` methods. Avoid calling this query directly.

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

Returns the type of the definition given by `DefId`.

For type aliases (whether eager or lazy) and associated types, this returns the underlying aliased type (not the corresponding alias type).

For opaque types, this returns and thus reveals the hidden type! If you want to detect cycle errors use `type_of_opaque` instead.

To clarify, for type definitions, this does not return the “type of a type” (aka kind or sort) in the type-theoretical sense! It merely returns the type primarily associated with it.

##### §Panics

This query will panic if the given definition doesn’t (and can’t conceptually) have an (underlying) type.

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

Returns the generics of the definition given by `DefId`.

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

Returns the explicitly user-written bounds on the associated or opaque type given by `DefId` that must be proven true at definition site (and which can be assumed at usage sites).

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.

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

Syntactially, these are the bounds written on associated types in trait definitions, or those after the `impl` keyword for an opaque:

ⓘ

    trait Trait { type X: Bound + 'lt; }
    //                    ^^^^^^^^^^^
    fn function() -> impl Debug + Display { /*...*/ }
    //                    ^^^^^^^^^^^^^^^

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

Returns the explicitly user-written bounds that share the `Self` type of the item.

These are a subset of the explicit item bounds that may explicitly be used for things like closure signature deduction.

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + 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: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

Checks for the nearest `#[coverage(off)]` or `#[coverage(on)]` on this def and any enclosing defs, up to the crate root.

Returns `false` if `#[coverage(off)]` was found, or `true` if either `#[coverage(on)]` or no coverage attribute was found.

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

Returns the explicitly user-written predicates of the definition given by `DefId` that must be proven true at usage sites (and which can be assumed at definition site).

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

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

Returns the inferred outlives-predicates of the item given by `DefId`.

E.g., for `struct Foo<'a, T> { x: &'a T }`, this would return `[T: 'a]`.

Tip: You can use `#[rustc_dump_inferred_outlives]` on an item to basically print the result of this query for use in UI tests or for debugging purposes.

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

Returns the constness of the function-like1 definition given by `DefId`.

Tuple struct/variant constructors are always const, foreign functions are never const. The rest is const iff marked with keyword `const` (or rather its parent in the case of associated functions).

Do not call this query directly. It is only meant to cache the base data for the higher-level functions. Consider using `is_const_fn` or `is_const_trait_impl` instead.

Also note that neither of them takes into account feature gates, stability and const predicates/conditions!

##### §Panics

This query will panic if the given definition is not function-like1.

1. Tuple struct/variant constructors, closures and free, associated and foreign functions. ↩ 1 2

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + 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: IntoQueryKey<Key<'tcx>> + 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: IntoQueryKey<Key<'tcx>> + 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: IntoQueryKey<Key<'tcx>> + 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: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

Gets the span for the definition.

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + 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: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

Returns the `CodegenFnAttrs` for the item at `def_id`.

If possible, use `tcx.codegen_instance_attrs` instead. That function takes the instance kind into account.

For example, the `#[naked]` attribute should be applied for `InstanceKind::Item`, but should not be applied if the instance kind is `InstanceKind::ReifyShim`. Using this query would include the attribute regardless of the actual instance kind at the call site.

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + 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.

You should almost certainly not use this. If you already have an InferCtxt, then you should also probably have a `ParamEnv` from when it was built. If you don’t, then you should take a `TypingEnv` to ensure that you handle opaque types correctly.

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

Returns whether the impl or associated function has the `default` keyword. Note: This will ICE on inherent impl items. Consider using `AssocItem::defaultness`.

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + 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: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

Gets the name of the crate.

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + 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: IntoQueryKey<Key<'tcx>> + 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: IntoQueryKey<Key<'tcx>> + 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

Source§

### impl<'tcx, K: IntoQueryKey<Key<'tcx>> + Copy> TyCtxtFeed<'tcx, K>

Source

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

Checks for the nearest `#[sanitize(xyz = "off")]` or `#[sanitize(xyz = "on")]` on this def and any enclosing defs, up to the crate root.

Returns the sanitizer settings for this def.

Source§

### impl<'tcx, K: Copy> TyCtxtFeed<'tcx, K>

Source

#### pub fn key(&self) -> K

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)

## Trait Implementations§

Source§

### impl<K: Copy> !StableHash for TyCtxtFeed<'_, K>

Only queries that create a `DefId` are allowed to feed queries for that `DefId`.

Source§

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

Source§

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

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<'tcx, K: Copy + Copy> Copy for TyCtxtFeed<'tcx, K>

## Auto Trait Implementations§

§

### impl<'tcx, K> !RefUnwindSafe for TyCtxtFeed<'tcx, K>

§

### impl<'tcx, K> !Send for TyCtxtFeed<'tcx, K>

§

### impl<'tcx, K> !Sync for TyCtxtFeed<'tcx, K>

§

### impl<'tcx, K> !UnwindSafe for TyCtxtFeed<'tcx, K>

§

### impl<'tcx, K> DynSend for TyCtxtFeed<'tcx, K>
where K: DynSend,

§

### impl<'tcx, K> DynSync for TyCtxtFeed<'tcx, K>
where K: DynSync,

§

### impl<'tcx, K> Freeze for TyCtxtFeed<'tcx, K>
where K: Freeze,

§

### impl<'tcx, K> Unpin for TyCtxtFeed<'tcx, K>
where K: Unpin,

§

### impl<'tcx, K> UnsafeUnpin for TyCtxtFeed<'tcx, K>
where K: UnsafeUnpin,

## 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, 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§

#### fn __clone_box(&self, _: Private) -> *mut ()

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