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

pub struct TypeckResults<'tcx> {
    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>>>,
    pub upvar_capture_map: UpvarCaptureMap<'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: FxHashMap<DefId, ResolvedOpaqueTy<'tcx>>,
    pub closure_captures: UpvarListMap,
    pub closure_min_captures: MinCaptureInformationMap<'tcx>,
    pub generator_interior_types: Binder<Vec<GeneratorInteriorTypeCause<'tcx>>>,
    pub treat_byte_string_as_slice: ItemLocalSet,


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

upvar_capture_map: UpvarCaptureMap<'tcx>


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.

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

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

closure_captures: UpvarListMap

Given the closure ID this map provides the list of UpvarIDs used by it. The upvarID contains the HIR node ID and it also contains the full path leading to the member of the struct or tuple that is used instead of the entire variable.

closure_min_captures: MinCaptureInformationMap<'tcx>

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

generator_interior_types: Binder<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.


impl<'tcx> TypeckResults<'tcx>[src]

pub fn new(hir_owner: LocalDefId) -> TypeckResults<'tcx>[src]

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

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

pub fn type_dependent_defs(
) -> LocalTableInContext<'_, Result<(DefKind, DefId), ErrorReported>>

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

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

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

pub fn field_indices(&self) -> LocalTableInContext<'_, usize>[src]

pub fn field_indices_mut(&mut self) -> LocalTableInContextMut<'_, usize>[src]

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

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

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

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

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

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

pub fn node_substs_mut(&mut self) -> LocalTableInContextMut<'_, SubstsRef<'tcx>>[src]

pub fn node_substs(&self, id: HirId) -> SubstsRef<'tcx>[src]

pub fn node_substs_opt(&self, id: HirId) -> Option<SubstsRef<'tcx>>[src]

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

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

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

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

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

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

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]

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

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

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

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

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

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

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

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

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

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

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

pub fn upvar_capture(&self, upvar_id: UpvarId) -> UpvarCapture<'tcx>[src]

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

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

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

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

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

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

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

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

pub fn coercion_casts(&self) -> &ItemLocalSet[src]

Trait Implementations

impl<'tcx> ArenaAllocatable<'tcx, TypeckResults<'tcx>> for TypeckResults<'tcx>[src]

impl<'tcx> Debug for TypeckResults<'tcx>[src]

impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for &'tcx TypeckResults<'tcx>[src]

impl<'tcx, __D: TyDecoder<'tcx>> Decodable<__D> for TypeckResults<'tcx>[src]

impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for &'tcx TypeckResults<'tcx>[src]

impl<'tcx, __E: TyEncoder<'tcx>> Encodable<__E> for TypeckResults<'tcx>[src]

impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckResults<'tcx>[src]

impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for TypeckResults<'tcx>[src]

Auto Trait Implementations

impl<'tcx> !RefUnwindSafe for TypeckResults<'tcx>[src]

impl<'tcx> !Send for TypeckResults<'tcx>[src]

impl<'tcx> !Sync for TypeckResults<'tcx>[src]

impl<'tcx> Unpin for TypeckResults<'tcx>[src]

impl<'tcx> !UnwindSafe for TypeckResults<'tcx>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<'a, T> Captures<'a> for T where
    T: ?Sized

impl<T> From<T> for T[src]

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

impl<T> MaybeResult<T> for T[src]

type Error = !

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

type Error = Infallible

The type returned in the event of a conversion error.

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

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]