Struct rustc_middle::ty::context::TypeckResults[][src]

pub struct TypeckResults<'tcx> {
Show 22 fields pub hir_owner: LocalDefId, type_dependent_defs: ItemLocalMap<Result<(DefKind, DefId), ErrorReported>>, field_indices: ItemLocalMap<usize>, node_types: ItemLocalMap<Ty<'tcx>>, node_substs: ItemLocalMap<SubstsRef<'tcx>>, user_provided_types: ItemLocalMap<CanonicalUserType<'tcx>>, pub user_provided_sigs: DefIdMap<CanonicalPolyFnSig<'tcx>>, adjustments: ItemLocalMap<Vec<Adjustment<'tcx>>>, pat_binding_modes: ItemLocalMap<BindingMode>, pat_adjustments: ItemLocalMap<Vec<Ty<'tcx>>>, closure_kind_origins: ItemLocalMap<(Span, HirPlace<'tcx>)>, liberated_fn_sigs: ItemLocalMap<FnSig<'tcx>>, fru_field_types: ItemLocalMap<Vec<Ty<'tcx>>>, coercion_casts: ItemLocalSet, pub used_trait_imports: Lrc<FxHashSet<LocalDefId>>, pub tainted_by_errors: Option<ErrorReported>, pub concrete_opaque_types: FxHashSet<DefId>, pub closure_min_captures: MinCaptureInformationMap<'tcx>, pub closure_fake_reads: FxHashMap<DefId, Vec<(HirPlace<'tcx>, FakeReadCause, HirId)>>, pub generator_interior_types: Binder<'tcx, Vec<GeneratorInteriorTypeCause<'tcx>>>, pub treat_byte_string_as_slice: ItemLocalSet, pub closure_size_eval: FxHashMap<DefId, ClosureSizeProfileData<'tcx>>,
}

Fields

hir_owner: LocalDefId

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

type_dependent_defs: ItemLocalMap<Result<(DefKind, DefId), ErrorReported>>

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

field_indices: ItemLocalMap<usize>

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 until after typeck. See typeck::check::fn_ctxt for details.

node_substs: ItemLocalMap<SubstsRef<'tcx>>

Stores the type parameters which were substituted 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 substitutions 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 substitutions would include only for<X> { Vec<X> }.

See also AscribeUserType statement in MIR.

user_provided_sigs: DefIdMap<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 hir::BindingAnnotation.

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

closure_kind_origins: ItemLocalMap<(Span, HirPlace<'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 ReFree) 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: Lrc<FxHashSet<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<ErrorReported>

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

concrete_opaque_types: FxHashSet<DefId>

All the opaque types that are restricted to concrete types by this function.

closure_min_captures: MinCaptureInformationMap<'tcx>

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

closure_fake_reads: FxHashMap<DefId, Vec<(HirPlace<'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.

generator_interior_types: Binder<'tcx, Vec<GeneratorInteriorTypeCause<'tcx>>>

Stores the type, expression, span and optional scope span of all types that are live across the yield of this generator (if a generator).

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: FxHashMap<DefId, ClosureSizeProfileData<'tcx>>

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

Implementations

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

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

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

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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