pub(crate) fn type_check<'gcx, 'tcx>(
    infcx: &InferCtxt<'_, 'gcx, 'tcx>,
    param_env: ty::ParamEnv<'gcx>,
    mir: &Mir<'tcx>,
    mir_def_id: DefId,
    universal_regions: &Rc<UniversalRegions<'tcx>>,
    location_table: &LocationTable,
    borrow_set: &BorrowSet<'tcx>,
    all_facts: &mut Option<AllFacts>,
    flow_inits: &mut FlowAtLocation<MaybeInitializedPlaces<'_, 'gcx, 'tcx>>,
    move_data: &MoveData<'tcx>,
    elements: &Rc<RegionValueElements>,
    errors_buffer: &mut Vec<Diagnostic>,
) -> MirTypeckResults<'tcx> {
    let implicit_region_bound = infcx.tcx.mk_region(ty::ReVar(universal_regions.fr_fn_body));
    let mut constraints = MirTypeckRegionConstraints {
        liveness_constraints: LivenessValues::new(elements),
        outlives_constraints: ConstraintSet::default(),
        type_tests: Vec::default(),
    };

    let CreateResult {
        universal_region_relations,
        region_bound_pairs,
        normalized_inputs_and_output,
    } = free_region_relations::create(
        infcx,
        mir_def_id,
        param_env,
        location_table,
        Some(implicit_region_bound),
        universal_regions,
        &mut constraints,
        all_facts,
    );

    let (liveness, liveness_map) = {
        let mut borrowck_context = BorrowCheckContext {
            universal_regions,
            location_table,
            borrow_set,
            all_facts,
            constraints: &mut constraints,
        };

        type_check_internal(
            infcx,
            mir_def_id,
            param_env,
            mir,
            &region_bound_pairs,
            Some(implicit_region_bound),
            Some(&mut borrowck_context),
            Some(errors_buffer),
            |cx| {
                cx.equate_inputs_and_outputs(
                    mir,
                    mir_def_id,
                    universal_regions,
                    &universal_region_relations,
                    &normalized_inputs_and_output,
                );
                liveness::generate(cx, mir, flow_inits, move_data)
            },
        )
    };

    MirTypeckResults {
        constraints,
        universal_region_relations,
        liveness,
        liveness_map,
    }
}
/// 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 is 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.
///
/// # Parameters
///
/// - `infcx` -- inference context to use
/// - `param_env` -- parameter environment to use for trait solving
/// - `mir` -- MIR to type-check
/// - `mir_def_id` -- DefId from which the MIR is derived (must be local)
/// - `region_bound_pairs` -- the implied outlives obligations between type parameters
///   and lifetimes (e.g., `&'a T` implies `T: 'a`)
/// - `implicit_region_bound` -- a region which all generic parameters are assumed
///   to outlive; should represent the fn body
/// - `input_tys` -- fully liberated, but **not** normalized, expected types of the arguments;
///   the types of the input parameters found in the MIR itself will be equated with these
/// - `output_ty` -- fully liberaetd, but **not** normalized, expected return type;
///   the type for the RETURN_PLACE will be equated with this
/// - `liveness` -- results of a liveness computation on the MIR; used to create liveness
///   constraints for the regions in the types of variables
/// - `flow_inits` -- results of a maybe-init dataflow analysis
/// - `move_data` -- move-data constructed when performing the maybe-init dataflow analysis
/// - `errors_buffer` -- errors are sent here for future reporting
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 is 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.


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 is 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 .
pub(crate) fn type_check<'gcx, 'tcx>(
    infcx: &InferCtxt<'_, 'gcx, 'tcx>,
    param_env: ty::ParamEnv<'gcx>,
    mir: &Mir<'tcx>,
    mir_def_id: DefId,
    universal_regions: &Rc<UniversalRegions<'tcx>>,
    location_table: &LocationTable,
    borrow_set: &BorrowSet<'tcx>,
    all_facts: &mut Option<AllFacts>,
    flow_inits: &mut FlowAtLocation<MaybeInitializedPlaces<'_, 'gcx, 'tcx>>,
    move_data: &MoveData<'tcx>,
    elements: &Rc<RegionValueElements>,
    errors_buffer: &mut Vec<Diagnostic>,
) -> MirTypeckResults<'tcx> {
    let implicit_region_bound = infcx.tcx.mk_region(ty::ReVar(universal_regions.fr_fn_body));
    let mut constraints = MirTypeckRegionConstraints {
        liveness_constraints: LivenessValues::new(elements),
        outlives_constraints: ConstraintSet::default(),
        type_tests: Vec::default(),
    };
    let CreateResult {
        universal_region_relations,
        region_bound_pairs,
        normalized_inputs_and_output,
    } = free_region_relations::create(
        infcx,
        mir_def_id,
        param_env,
        location_table,
        Some(implicit_region_bound),
        universal_regions,
        &mut constraints,
        all_facts,
    );
    let (liveness, liveness_map) = {
        let mut borrowck_context = BorrowCheckContext {
            universal_regions,
            location_table,
            borrow_set,
            all_facts,
            constraints: &mut constraints,
        };
        type_check_internal(
            infcx,
            mir_def_id,
            param_env,
            mir,
            &region_bound_pairs,
            Some(implicit_region_bound),
            Some(&mut borrowck_context),
            Some(errors_buffer),
            |cx| {
                cx.equate_inputs_and_outputs(
                    mir,
                    mir_def_id,
                    universal_regions,
                    &universal_region_relations,
                    &normalized_inputs_and_output,
                );
                liveness::generate(cx, mir, flow_inits, move_data)
            },
        )
    };
    MirTypeckResults {
        constraints,
        universal_region_relations,
        liveness,
        liveness_map,
    }
}
pub ( crate ) fn type_check < ' gcx , ' tcx > ( infcx : & InferCtxt < ' _ , ' gcx , ' tcx > , param_env : ty :: ParamEnv < ' gcx > , mir : & Mir < ' tcx > , mir_def_id : DefId , universal_regions : & Rc < UniversalRegions < ' tcx > > , location_table : & LocationTable , borrow_set : & BorrowSet < ' tcx > , all_facts : & mut Option < AllFacts > , flow_inits : & mut FlowAtLocation < MaybeInitializedPlaces < ' _ , ' gcx , ' tcx > > , move_data : & MoveData < ' tcx > , elements : & Rc < RegionValueElements > , errors_buffer : & mut Vec < Diagnostic > , ) -> MirTypeckResults < ' tcx > { let implicit_region_bound = infcx . tcx . mk_region ( ty :: ReVar ( universal_regions . fr_fn_body ) ) ; let mut constraints = MirTypeckRegionConstraints { liveness_constraints : LivenessValues :: new ( elements ) , outlives_constraints : ConstraintSet :: default ( ) , type_tests : Vec :: default ( ) , } ; let CreateResult { universal_region_relations , region_bound_pairs , normalized_inputs_and_output , } = free_region_relations :: create ( infcx , mir_def_id , param_env , location_table , Some ( implicit_region_bound ) , universal_regions , & mut constraints , all_facts , ) ; let ( liveness , liveness_map ) = { let mut borrowck_context = BorrowCheckContext { universal_regions , location_table , borrow_set , all_facts , constraints : & mut constraints , } ; type_check_internal ( infcx , mir_def_id , param_env , mir , & region_bound_pairs , Some ( implicit_region_bound ) , Some ( & mut borrowck_context ) , Some ( errors_buffer ) , | cx | { cx . equate_inputs_and_outputs ( mir , mir_def_id , universal_regions , & universal_region_relations , & normalized_inputs_and_output , ) ; liveness :: generate ( cx , mir , flow_inits , move_data ) } , ) } ; MirTypeckResults { constraints , universal_region_relations , liveness , liveness_map , } }
Type checks the given `mir` in the context of the inference
context `infcx`.
Type checks the given ` mir ` in the context of the inference context ` infcx ` .
infcx
&InferCtxt<'_, 'gcx, 'tcx>
param_env
ty::ParamEnv<'gcx>
mir
&Mir<'tcx>
mir_def_id
DefId
universal_regions
&Rc<UniversalRegions<'tcx>>
location_table
&LocationTable
borrow_set
&BorrowSet<'tcx>
all_facts
&mut Option<AllFacts>
flow_inits
&mut FlowAtLocation<MaybeInitializedPlaces<'_, 'gcx, 'tcx>>
move_data
&MoveData<'tcx>
elements
&Rc<RegionValueElements>
errors_buffer
&mut Vec<Diagnostic>
infcx
&InferCtxt<'_, 'gcx, 'tcx>
inference context to use
inference context to use
param_env
ty::ParamEnv<'gcx>
parameter environment to use for trait solving
parameter environment to use for trait solving
mir
&Mir<'tcx>
MIR to type-check
MIR to type - check
mir_def_id
DefId
DefId from which the MIR is derived (must be local)
DefId from which the MIR is derived ( must be local )
universal_regions
&Rc<UniversalRegions<'tcx>>
location_table
&LocationTable
borrow_set
&BorrowSet<'tcx>
all_facts
&mut Option<AllFacts>
flow_inits
&mut FlowAtLocation<MaybeInitializedPlaces<'_, 'gcx, 'tcx>>
results of a maybe-init dataflow analysis
results of a maybe - init dataflow analysis
move_data
&MoveData<'tcx>
move-data constructed when performing the maybe-init dataflow analysis
move - data constructed when performing the maybe - init dataflow analysis
elements
&Rc<RegionValueElements>
errors_buffer
&mut Vec<Diagnostic>
errors are sent here for future reporting
errors are sent here for future reporting
region_bound_pairs
the implied outlives obligations between type parameters
and lifetimes
the implied outlives obligations between type parameters and lifetimes
implicit_region_bound
a region which all generic parameters are assumed
to outlive; should represent the fn body
a region which all generic parameters are assumed to outlive ; should represent the fn body
input_tys
fully liberated, but **not** normalized, expected types of the arguments;
the types of the input parameters found in the MIR itself will be equated with these
fully liberated but ** not ** normalized expected types of the arguments ; the types of the input parameters found in the MIR itself will be equated with these
output_ty
fully liberaetd, but **not** normalized, expected return type;
the type for the RETURN_PLACE will be equated with this
fully liberaetd but ** not ** normalized expected return type ; the type for the RETURN_PLACE will be equated with this
liveness
results of a liveness computation on the MIR; used to create liveness
constraints for the regions in the types of variables
results of a liveness computation on the MIR ; used to create liveness constraints for the regions in the types of variables