Struct hir_ty::InferenceResult
source · pub struct InferenceResult {
pub tuple_field_access_types: FxHashMap<TupleId, Substitution>,
pub diagnostics: Vec<InferenceDiagnostic>,
pub type_of_expr: ArenaMap<ExprId, Ty>,
pub type_of_pat: ArenaMap<PatId, Ty>,
pub type_of_binding: ArenaMap<BindingId, Ty>,
pub type_of_rpit: ArenaMap<ImplTraitIdx, Ty>,
pub type_of_for_iterator: FxHashMap<ExprId, Ty>,
pub pat_adjustments: FxHashMap<PatId, Vec<Ty>>,
pub binding_modes: ArenaMap<PatId, BindingMode>,
pub expr_adjustments: FxHashMap<ExprId, Vec<Adjustment>>,
pub mutated_bindings_in_closure: FxHashSet<BindingId>,
pub coercion_casts: FxHashSet<ExprId>,
/* private fields */
}
Expand description
The result of type inference: A mapping from expressions and patterns to types.
When you add a field that stores types (including Substitution
and the like), don’t forget
resolve_completely()
’ing them in InferenceContext::resolve_all()
. Inference variables must
not appear in the final inference result.
Fields§
§tuple_field_access_types: FxHashMap<TupleId, Substitution>
Whenever a tuple field expression access a tuple field, we allocate a tuple id in
[InferenceContext
] and store the tuples substitution there. This map is the reverse of
that which allows us to resolve a [TupleFieldId
]s type.
diagnostics: Vec<InferenceDiagnostic>
§type_of_expr: ArenaMap<ExprId, Ty>
§type_of_pat: ArenaMap<PatId, Ty>
For each pattern record the type it resolves to.
Note: When a pattern type is resolved it may still contain unresolved or missing subpatterns or subpatterns of mismatched types.
type_of_binding: ArenaMap<BindingId, Ty>
§type_of_rpit: ArenaMap<ImplTraitIdx, Ty>
§type_of_for_iterator: FxHashMap<ExprId, Ty>
Type of the result of .into_iter()
on the for. ExprId
is the one of the whole for loop.
pat_adjustments: FxHashMap<PatId, Vec<Ty>>
Stores the types which were implicitly dereferenced in pattern binding modes.
binding_modes: ArenaMap<PatId, BindingMode>
Stores the binding mode (ref
in let ref x = 2
) of bindings.
This one is tied to the PatId
instead of BindingId
, because in some rare cases, a binding in an
or pattern can have multiple binding modes. For example:
fn foo(mut slice: &[u32]) -> usize {
slice = match slice {
[0, rest @ ..] | rest => rest,
};
}
the first rest
has implicit ref
binding mode, but the second rest
binding mode is move
.
expr_adjustments: FxHashMap<ExprId, Vec<Adjustment>>
§mutated_bindings_in_closure: FxHashSet<BindingId>
§coercion_casts: FxHashSet<ExprId>
Implementations§
source§impl InferenceResult
impl InferenceResult
pub fn method_resolution( &self, expr: ExprId, ) -> Option<(FunctionId, Substitution)>
pub fn field_resolution( &self, expr: ExprId, ) -> Option<Either<FieldId, TupleFieldId>>
pub fn variant_resolution_for_expr(&self, id: ExprId) -> Option<VariantId>
pub fn variant_resolution_for_pat(&self, id: PatId) -> Option<VariantId>
pub fn variant_resolution_for_expr_or_pat( &self, id: ExprOrPatId, ) -> Option<VariantId>
pub fn assoc_resolutions_for_expr( &self, id: ExprId, ) -> Option<(AssocItemId, Substitution)>
pub fn assoc_resolutions_for_pat( &self, id: PatId, ) -> Option<(AssocItemId, Substitution)>
pub fn assoc_resolutions_for_expr_or_pat( &self, id: ExprOrPatId, ) -> Option<(AssocItemId, Substitution)>
pub fn type_mismatch_for_expr(&self, expr: ExprId) -> Option<&TypeMismatch>
pub fn type_mismatch_for_pat(&self, pat: PatId) -> Option<&TypeMismatch>
pub fn type_mismatches( &self, ) -> impl Iterator<Item = (ExprOrPatId, &TypeMismatch)>
pub fn expr_type_mismatches( &self, ) -> impl Iterator<Item = (ExprId, &TypeMismatch)>
pub fn closure_info(&self, closure: &ClosureId) -> &(Vec<CapturedItem>, FnTrait)
pub fn type_of_expr_or_pat(&self, id: ExprOrPatId) -> Option<&Ty>
Trait Implementations§
source§impl Clone for InferenceResult
impl Clone for InferenceResult
source§fn clone(&self) -> InferenceResult
fn clone(&self) -> InferenceResult
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for InferenceResult
impl Debug for InferenceResult
source§impl Default for InferenceResult
impl Default for InferenceResult
source§fn default() -> InferenceResult
fn default() -> InferenceResult
source§impl Index<ExprOrPatId> for InferenceResult
impl Index<ExprOrPatId> for InferenceResult
source§impl Index<Idx<Binding>> for InferenceResult
impl Index<Idx<Binding>> for InferenceResult
source§impl Index<Idx<Expr>> for InferenceResult
impl Index<Idx<Expr>> for InferenceResult
source§impl Index<Idx<Pat>> for InferenceResult
impl Index<Idx<Pat>> for InferenceResult
source§impl PartialEq for InferenceResult
impl PartialEq for InferenceResult
impl Eq for InferenceResult
impl StructuralPartialEq for InferenceResult
Auto Trait Implementations§
impl Freeze for InferenceResult
impl RefUnwindSafe for InferenceResult
impl Send for InferenceResult
impl Sync for InferenceResult
impl Unpin for InferenceResult
impl UnwindSafe for InferenceResult
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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