rustc_middle::ty

Struct TypeckResults

Source
pub struct TypeckResults<'tcx> {
Show 26 fields pub hir_owner: OwnerId, type_dependent_defs: ItemLocalMap<Result<(DefKind, DefId), ErrorGuaranteed>>, field_indices: ItemLocalMap<FieldIdx>, node_types: ItemLocalMap<Ty<'tcx>>, node_args: ItemLocalMap<GenericArgsRef<'tcx>>, user_provided_types: ItemLocalMap<CanonicalUserType<'tcx>>, pub user_provided_sigs: LocalDefIdMap<CanonicalPolyFnSig<'tcx>>, adjustments: ItemLocalMap<Vec<Adjustment<'tcx>>>, pat_binding_modes: ItemLocalMap<BindingMode>, rust_2024_migration_desugared_pats: ItemLocalMap<Vec<(Span, String)>>, pat_adjustments: ItemLocalMap<Vec<Ty<'tcx>>>, skipped_ref_pats: ItemLocalSet, closure_kind_origins: ItemLocalMap<(Span, Place<'tcx>)>, liberated_fn_sigs: ItemLocalMap<FnSig<'tcx>>, fru_field_types: ItemLocalMap<Vec<Ty<'tcx>>>, coercion_casts: ItemLocalSet, pub used_trait_imports: UnordSet<LocalDefId>, pub tainted_by_errors: Option<ErrorGuaranteed>, pub concrete_opaque_types: FxIndexMap<OpaqueTypeKey<'tcx>, OpaqueHiddenType<'tcx>>, pub closure_min_captures: MinCaptureInformationMap<'tcx>, pub closure_fake_reads: LocalDefIdMap<Vec<(Place<'tcx>, FakeReadCause, HirId)>>, pub rvalue_scopes: RvalueScopes, pub coroutine_stalled_predicates: FxIndexSet<(Predicate<'tcx>, ObligationCause<'tcx>)>, pub treat_byte_string_as_slice: ItemLocalSet, pub closure_size_eval: LocalDefIdMap<ClosureSizeProfileData<'tcx>>, offset_of_data: ItemLocalMap<(Ty<'tcx>, Vec<(VariantIdx, FieldIdx)>)>,
}

Fields§

§hir_owner: OwnerId

The HirId::owner all ItemLocalIds in this table are relative to.

§type_dependent_defs: ItemLocalMap<Result<(DefKind, DefId), ErrorGuaranteed>>

Resolved definitions for <T>::X associated paths and method calls, including those of overloaded operators.

§field_indices: ItemLocalMap<FieldIdx>

Resolved field indices for field accesses in expressions (S { field }, obj.field) or patterns (S { field }). The index is often useful by itself, but to learn more about the field you also need definition of the variant to which the field belongs, but it may not exist if it’s a tuple field (tuple.0).

§node_types: ItemLocalMap<Ty<'tcx>>

Stores the types for various nodes in the AST. Note that this table is not guaranteed to be populated outside inference. See typeck::check::fn_ctxt for details.

§node_args: ItemLocalMap<GenericArgsRef<'tcx>>

Stores the type parameters which were instantiated to obtain the type of this node. This only applies to nodes that refer to entities parameterized by type parameters, such as generic fns, types, or other items.

§user_provided_types: ItemLocalMap<CanonicalUserType<'tcx>>

This will either store the canonicalized types provided by the user or the generic parameters that the user explicitly gave (if any) attached to id. These will not include any inferred values. The canonical form is used to capture things like _ or other unspecified values.

For example, if the user wrote foo.collect::<Vec<_>>(), then the canonical generic parameters would include only for<X> { Vec<X> }.

See also AscribeUserType statement in MIR.

§user_provided_sigs: LocalDefIdMap<CanonicalPolyFnSig<'tcx>>

Stores the canonicalized types provided by the user. See also AscribeUserType statement in MIR.

§adjustments: ItemLocalMap<Vec<Adjustment<'tcx>>>§pat_binding_modes: ItemLocalMap<BindingMode>

Stores the actual binding mode for all instances of BindingMode.

§rust_2024_migration_desugared_pats: ItemLocalMap<Vec<(Span, String)>>

Top-level patterns whose match ergonomics need to be desugared by the Rust 2021 -> 2024 migration lint. Problematic subpatterns are stored in the Vec for the lint to highlight.

§pat_adjustments: ItemLocalMap<Vec<Ty<'tcx>>>

Stores the types which were implicitly dereferenced in pattern binding modes for later usage in THIR lowering. For example,

match &&Some(5i32) {
    Some(n) => {},
    _ => {},
}

leads to a vec![&&Option<i32>, &Option<i32>]. Empty vectors are not stored.

See: https://github.com/rust-lang/rfcs/blob/master/text/2005-match-ergonomics.md#definitions

§skipped_ref_pats: ItemLocalSet

Set of reference patterns that match against a match-ergonomics inserted reference (as opposed to against a reference in the scrutinee type).

§closure_kind_origins: ItemLocalMap<(Span, Place<'tcx>)>

Records the reasons that we picked the kind of each closure; not all closures are present in the map.

§liberated_fn_sigs: ItemLocalMap<FnSig<'tcx>>

For each fn, records the “liberated” types of its arguments and return type. Liberated means that all bound regions (including late-bound regions) are replaced with free equivalents. This table is not used in codegen (since regions are erased there) and hence is not serialized to metadata.

This table also contains the “revealed” values for any impl Trait that appear in the signature and whose values are being inferred by this function.

§Example

fn foo(x: &u32) -> impl Debug { *x }

The function signature here would be:

for<'a> fn(&'a u32) -> Foo

where Foo is an opaque type created for this function.

The liberated form of this would be

fn(&'a u32) -> u32

Note that 'a is not bound (it would be an ReLateParam) and that the Foo opaque type is replaced by its hidden type.

§fru_field_types: ItemLocalMap<Vec<Ty<'tcx>>>

For each FRU expression, record the normalized types of the fields of the struct - this is needed because it is non-trivial to normalize while preserving regions. This table is used only in MIR construction and hence is not serialized to metadata.

§coercion_casts: ItemLocalSet

For every coercion cast we add the HIR node ID of the cast expression to this set.

§used_trait_imports: UnordSet<LocalDefId>

Set of trait imports actually used in the method resolution. This is used for warning unused imports. During type checking, this Lrc should not be cloned: it must have a ref-count of 1 so that we can insert things into the set mutably.

§tainted_by_errors: Option<ErrorGuaranteed>

If any errors occurred while type-checking this body, this field will be set to Some(ErrorGuaranteed).

§concrete_opaque_types: FxIndexMap<OpaqueTypeKey<'tcx>, OpaqueHiddenType<'tcx>>

All the opaque types that have hidden types set by this function. We also store the type here, so that the compiler can use it as a hint for figuring out hidden types, even if they are only set in dead code (which doesn’t show up in MIR).

§closure_min_captures: MinCaptureInformationMap<'tcx>

Tracks the minimum captures required for a closure; see MinCaptureInformationMap for more details.

§closure_fake_reads: LocalDefIdMap<Vec<(Place<'tcx>, FakeReadCause, HirId)>>

Tracks the fake reads required for a closure and the reason for the fake read. When performing pattern matching for closures, there are times we don’t end up reading places that are mentioned in a closure (because of _ patterns). However, to ensure the places are initialized, we introduce fake reads. Consider these two examples:

let x: u8;
let c = || match x { _ => () };

In this example, we don’t need to actually read/borrow x in c, and so we don’t want to capture it. However, we do still want an error here, because x should have to be initialized at the point where c is created. Therefore, we add a “fake read” instead.

let c = || {
    let (t1, t2) = t;
}

In the second example, we capture the disjoint fields of t (t.0 & t.1), but we never capture t. This becomes an issue when we build MIR as we require information on t in order to create place t.0 and t.1. We can solve this issue by fake reading t.

§rvalue_scopes: RvalueScopes

Tracks the rvalue scoping rules which defines finer scoping for rvalue expressions by applying extended parameter rules. Details may be find in rustc_hir_analysis::check::rvalue_scopes.

§coroutine_stalled_predicates: FxIndexSet<(Predicate<'tcx>, ObligationCause<'tcx>)>

Stores the predicates that apply on coroutine witness types. formatting modified file tests/ui/coroutine/retain-resume-ref.rs

§treat_byte_string_as_slice: ItemLocalSet

We sometimes treat byte string literals (which are of type &[u8; N]) as &[u8], depending on the pattern in which they are used. This hashset records all instances where we behave like this to allow const_to_pat to reliably handle this situation.

§closure_size_eval: LocalDefIdMap<ClosureSizeProfileData<'tcx>>

Contains the data for evaluating the effect of feature capture_disjoint_fields on closure size.

§offset_of_data: ItemLocalMap<(Ty<'tcx>, Vec<(VariantIdx, FieldIdx)>)>

Container types and field indices of offset_of! expressions

Implementations§

Source§

impl<'tcx> TypeckResults<'tcx>

Source

pub fn new(hir_owner: OwnerId) -> TypeckResults<'tcx>

Source

pub fn qpath_res(&self, qpath: &QPath<'_>, id: HirId) -> Res

Returns the final resolution of a QPath in an Expr or Pat node.

Source

pub fn type_dependent_defs( &self, ) -> LocalTableInContext<'_, Result<(DefKind, DefId), ErrorGuaranteed>>

Source

pub fn type_dependent_def(&self, id: HirId) -> Option<(DefKind, DefId)>

Source

pub fn type_dependent_def_id(&self, id: HirId) -> Option<DefId>

Source

pub fn type_dependent_defs_mut( &mut self, ) -> LocalTableInContextMut<'_, Result<(DefKind, DefId), ErrorGuaranteed>>

Source

pub fn field_indices(&self) -> LocalTableInContext<'_, FieldIdx>

Source

pub fn field_indices_mut(&mut self) -> LocalTableInContextMut<'_, FieldIdx>

Source

pub fn field_index(&self, id: HirId) -> FieldIdx

Source

pub fn opt_field_index(&self, id: HirId) -> Option<FieldIdx>

Source

pub fn user_provided_types( &self, ) -> LocalTableInContext<'_, CanonicalUserType<'tcx>>

Source

pub fn user_provided_types_mut( &mut self, ) -> LocalTableInContextMut<'_, CanonicalUserType<'tcx>>

Source

pub fn node_types(&self) -> LocalTableInContext<'_, Ty<'tcx>>

Source

pub fn node_types_mut(&mut self) -> LocalTableInContextMut<'_, Ty<'tcx>>

Source

pub fn node_type(&self, id: HirId) -> Ty<'tcx>

Source

pub fn node_type_opt(&self, id: HirId) -> Option<Ty<'tcx>>

Source

pub fn node_args_mut( &mut self, ) -> LocalTableInContextMut<'_, GenericArgsRef<'tcx>>

Source

pub fn node_args(&self, id: HirId) -> GenericArgsRef<'tcx>

Source

pub fn node_args_opt(&self, id: HirId) -> Option<GenericArgsRef<'tcx>>

Source

pub fn pat_ty(&self, pat: &Pat<'_>) -> Ty<'tcx>

Returns the type of a pattern as a monotype. Like expr_ty, this function doesn’t provide type parameter args.

Source

pub fn expr_ty(&self, expr: &Expr<'_>) -> Ty<'tcx>

Returns the type of an expression as a monotype.

NB (1): This is the PRE-ADJUSTMENT TYPE for the expression. That is, in some cases, we insert Adjustment annotations such as auto-deref or auto-ref. The type returned by this function does not consider such adjustments. See Self::expr_ty_adjusted instead.

NB (2): This type doesn’t provide type parameter args; e.g., if you ask for the type of id in id(3), it will return fn(&isize) -> isize instead of fn(ty) -> T with T = isize.

Source

pub fn expr_ty_opt(&self, expr: &Expr<'_>) -> Option<Ty<'tcx>>

Source

pub fn adjustments(&self) -> LocalTableInContext<'_, Vec<Adjustment<'tcx>>>

Source

pub fn adjustments_mut( &mut self, ) -> LocalTableInContextMut<'_, Vec<Adjustment<'tcx>>>

Source

pub fn expr_adjustments(&self, expr: &Expr<'_>) -> &[Adjustment<'tcx>]

Source

pub fn expr_ty_adjusted(&self, expr: &Expr<'_>) -> Ty<'tcx>

Returns the type of expr, considering any Adjustment entry recorded for that expression.

Source

pub fn expr_ty_adjusted_opt(&self, expr: &Expr<'_>) -> Option<Ty<'tcx>>

Source

pub fn is_method_call(&self, expr: &Expr<'_>) -> bool

Source

pub fn extract_binding_mode( &self, s: &Session, id: HirId, sp: Span, ) -> Option<BindingMode>

Source

pub fn pat_binding_modes(&self) -> LocalTableInContext<'_, BindingMode>

Source

pub fn pat_binding_modes_mut( &mut self, ) -> LocalTableInContextMut<'_, BindingMode>

Source

pub fn pat_adjustments(&self) -> LocalTableInContext<'_, Vec<Ty<'tcx>>>

Source

pub fn pat_adjustments_mut( &mut self, ) -> LocalTableInContextMut<'_, Vec<Ty<'tcx>>>

Source

pub fn rust_2024_migration_desugared_pats( &self, ) -> LocalTableInContext<'_, Vec<(Span, String)>>

Source

pub fn rust_2024_migration_desugared_pats_mut( &mut self, ) -> LocalTableInContextMut<'_, Vec<(Span, String)>>

Source

pub fn skipped_ref_pats(&self) -> LocalSetInContext<'_>

Source

pub fn skipped_ref_pats_mut(&mut self) -> LocalSetInContextMut<'_>

Source

pub fn pat_has_ref_mut_binding(&self, pat: &Pat<'_>) -> bool

Does the pattern recursively contain a ref mut binding in it?

This is used to determined whether a deref pattern should emit a Deref or DerefMut call for its pattern scrutinee.

This is computed from the typeck results since we want to make sure to apply any match-ergonomics adjustments, which we cannot determine from the HIR alone.

Source

pub fn closure_min_captures_flattened( &self, closure_def_id: LocalDefId, ) -> impl Iterator<Item = &CapturedPlace<'tcx>>

For a given closure, returns the iterator of ty::CapturedPlaces that are captured by the closure.

Source

pub fn closure_kind_origins( &self, ) -> LocalTableInContext<'_, (Span, HirPlace<'tcx>)>

Source

pub fn closure_kind_origins_mut( &mut self, ) -> LocalTableInContextMut<'_, (Span, HirPlace<'tcx>)>

Source

pub fn liberated_fn_sigs(&self) -> LocalTableInContext<'_, FnSig<'tcx>>

Source

pub fn liberated_fn_sigs_mut( &mut self, ) -> LocalTableInContextMut<'_, FnSig<'tcx>>

Source

pub fn fru_field_types(&self) -> LocalTableInContext<'_, Vec<Ty<'tcx>>>

Source

pub fn fru_field_types_mut( &mut self, ) -> LocalTableInContextMut<'_, Vec<Ty<'tcx>>>

Source

pub fn is_coercion_cast(&self, hir_id: HirId) -> bool

Source

pub fn set_coercion_cast(&mut self, id: ItemLocalId)

Source

pub fn coercion_casts(&self) -> &ItemLocalSet

Source

pub fn offset_of_data( &self, ) -> LocalTableInContext<'_, (Ty<'tcx>, Vec<(VariantIdx, FieldIdx)>)>

Source

pub fn offset_of_data_mut( &mut self, ) -> LocalTableInContextMut<'_, (Ty<'tcx>, Vec<(VariantIdx, FieldIdx)>)>

Trait Implementations§

Source§

impl<'tcx> ArenaAllocatable<'tcx> for TypeckResults<'tcx>

Source§

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

Source§

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

Source§

impl<'tcx> Debug for TypeckResults<'tcx>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for &'tcx TypeckResults<'tcx>

Source§

fn decode(decoder: &mut D) -> Self

Source§

impl<'tcx, __D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<__D> for TypeckResults<'tcx>

Source§

fn decode(__decoder: &mut __D) -> Self

Source§

impl<'tcx, __E: TyEncoder<I = TyCtxt<'tcx>>> Encodable<__E> for TypeckResults<'tcx>

Source§

fn encode(&self, __encoder: &mut __E)

Source§

impl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for TypeckResults<'tcx>

Source§

fn hash_stable( &self, __hcx: &mut StableHashingContext<'__ctx>, __hasher: &mut StableHasher, )

Source§

impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> RefDecodable<'tcx, D> for TypeckResults<'tcx>

Source§

fn decode(decoder: &mut D) -> &'tcx Self

Auto Trait Implementations§

§

impl<'tcx> DynSend for TypeckResults<'tcx>

§

impl<'tcx> DynSync for TypeckResults<'tcx>

§

impl<'tcx> Freeze for TypeckResults<'tcx>

§

impl<'tcx> !RefUnwindSafe for TypeckResults<'tcx>

§

impl<'tcx> Send for TypeckResults<'tcx>

§

impl<'tcx> Sync for TypeckResults<'tcx>

§

impl<'tcx> Unpin for TypeckResults<'tcx>

§

impl<'tcx> !UnwindSafe for TypeckResults<'tcx>

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<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, 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<Tcx, T> DepNodeParams<Tcx> for T
where Tcx: DepContext, T: for<'a> HashStable<StableHashingContext<'a>> + Debug,

Source§

default fn fingerprint_style() -> FingerprintStyle

Source§

default fn to_fingerprint(&self, tcx: Tcx) -> Fingerprint

This method turns the parameters of a DepNodeConstructor into an opaque Fingerprint to be used in DepNode. Not all DepNodeParams support being turned into a Fingerprint (they don’t need to if the corresponding DepNode is anonymous).
Source§

default fn to_debug_str(&self, _: Tcx) -> String

Source§

default fn recover(_: Tcx, _: &DepNode) -> Option<T>

This method tries to recover the query key from the given DepNode, something which is needed when forcing DepNodes during red-green evaluation. The query system will only call this method if fingerprint_style() is not FingerprintStyle::Opaque. It is always valid to return None here, in which case incremental compilation will treat the query as having changed instead of forcing it.
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> 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, 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
where T: Send + Sync,

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