struct TypeChecker<'a, 'tcx> {
    infcx: &'a InferCtxt<'tcx>,
    param_env: ParamEnv<'tcx>,
    last_span: Span,
    body: &'a Body<'tcx>,
    user_type_annotations: &'a CanonicalUserTypeAnnotations<'tcx>,
    region_bound_pairs: &'a RegionBoundPairs<'tcx>,
    implicit_region_bound: Region<'tcx>,
    reported_errors: FxHashSet<(Ty<'tcx>, Span)>,
    borrowck_context: &'a mut BorrowCheckContext<'a, 'tcx>,
}
Expand description

The MIR type checker. Visits the MIR and enforces all the constraints needed for it to be valid and well-typed. Along the way, it accrues region constraints – these can later be used by NLL region checking.

Fields§

§infcx: &'a InferCtxt<'tcx>§param_env: ParamEnv<'tcx>§last_span: Span§body: &'a Body<'tcx>§user_type_annotations: &'a CanonicalUserTypeAnnotations<'tcx>

User type annotations are shared between the main MIR and the MIR of all of the promoted items.

§region_bound_pairs: &'a RegionBoundPairs<'tcx>§implicit_region_bound: Region<'tcx>§reported_errors: FxHashSet<(Ty<'tcx>, Span)>§borrowck_context: &'a mut BorrowCheckContext<'a, 'tcx>

Implementations§

Given some operation op that manipulates types, proves predicates, or otherwise uses the inference context, executes op and then executes all the further obligations that op returns. This will yield a set of outlives constraints amongst regions which are extracted and stored as having occurred at locations.

Any rustc_infer::infer operations that might generate region constraints should occur within this method so that those constraints can be properly localized!

Adds sufficient constraints to ensure that a R b where R depends on v:

  • “Covariant” a <: b
  • “Invariant” a == b
  • “Contravariant” a :> b

N.B., the type a is permitted to have unresolved inference variables, but not the type b.

Add sufficient constraints to ensure a == b. See also Self::relate_types.

Equate the inferred type and the annotated type for user type annotations

Try to relate sub <: sup

If this rvalue supports a user-given type annotation, then extract and return it. This represents the final type of the rvalue and will be unified with the inferred type.

Adds the constraints that arise from a borrow expression &'a P at the location L.

Parameters
  • location: the location L where the borrow expression occurs
  • borrow_region: the region 'a associated with the borrow
  • borrowed_place: the place P being borrowed

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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