pub(crate) fn type_check<'mir, 'tcx>(
    infcx: &BorrowckInferCtxt<'_, 'tcx>,
    param_env: ParamEnv<'tcx>,
    body: &Body<'tcx>,
    promoted: &IndexVec<Promoted, Body<'tcx>>,
    universal_regions: &Rc<UniversalRegions<'tcx>>,
    location_table: &LocationTable,
    borrow_set: &BorrowSet<'tcx>,
    all_facts: &mut Option<AllFacts>,
    flow_inits: &mut ResultsCursor<'mir, 'tcx, MaybeInitializedPlaces<'mir, 'tcx>>,
    move_data: &MoveData<'tcx>,
    elements: &Rc<RegionValueElements>,
    upvars: &[Upvar<'tcx>],
    use_polonius: bool
) -> MirTypeckResults<'tcx>
Expand description

Type checks the given mir in the context of the inference context infcx. Returns any region constraints that have yet to be proven. This result includes liveness constraints that ensure that regions appearing in the types of all local variables are live at all points where that local variable may later be used.

This phase of type-check ought to be infallible – this is because the original, HIR-based type-check succeeded. So if any errors occur here, we will get a bug! reported.


  • infcx – inference context to use
  • param_env – parameter environment to use for trait solving
  • body – MIR body to type-check
  • promoted – map of promoted constants within body
  • universal_regions – the universal regions from bodys function signature
  • location_table – MIR location map of body
  • borrow_set – information about borrows occurring in body
  • all_facts – when using Polonius, this is the generated set of Polonius facts
  • flow_inits – results of a maybe-init dataflow analysis
  • move_data – move-data constructed when performing the maybe-init dataflow analysis
  • elements – MIR region map