fn scrape_region_constraints<'gcx, 'tcx, R>(
    infcx: &InferCtxt<'_, 'gcx, 'tcx>,
    op: impl FnOnce() -> Fallible<InferOk<'tcx, R>>,
) -> Fallible<(R, Option<Rc<Vec<QueryRegionConstraint<'tcx>>>>)> {
    let mut fulfill_cx = TraitEngine::new(infcx.tcx);
    let dummy_body_id = ObligationCause::dummy().body_id;

    // During NLL, we expect that nobody will register region
    // obligations **except** as part of a custom type op (and, at the
    // end of each custom type op, we scrape out the region
    // obligations that resulted). So this vector should be empty on
    // entry.
    let pre_obligations = infcx.take_registered_region_obligations();
    assert!(
        pre_obligations.is_empty(),
        "scrape_region_constraints: incoming region obligations = {:#?}",
        pre_obligations,
    );

    let InferOk { value, obligations } = infcx.commit_if_ok(|_| op())?;
    debug_assert!(obligations.iter().all(|o| o.cause.body_id == dummy_body_id));
    fulfill_cx.register_predicate_obligations(infcx, obligations);
    if let Err(e) = fulfill_cx.select_all_or_error(infcx) {
        infcx.tcx.sess.diagnostic().delay_span_bug(
            DUMMY_SP,
            &format!("errors selecting obligation during MIR typeck: {:?}", e),
        );
    }

    let region_obligations = infcx.take_registered_region_obligations();

    let region_constraint_data = infcx.take_and_reset_region_constraints();

    let outlives = query_result::make_query_outlives(
        infcx.tcx,
        region_obligations
            .iter()
            .map(|(_, r_o)| (r_o.sup_type, r_o.sub_region))
            .map(|(ty, r)| (infcx.resolve_type_vars_if_possible(&ty), r)),
        &region_constraint_data,
    );

    if outlives.is_empty() {
        Ok((value, None))
    } else {
        Ok((value, Some(Rc::new(outlives))))
    }
}
/// Executes `op` and then scrapes out all the "old style" region
/// constraints that result, creating query-region-constraints.
Executes `op` and then scrapes out all the "old style" region
constraints that result, creating query-region-constraints.
Executes ` op ` and then scrapes out all the " old style " region constraints that result creating query - region - constraints .
fn scrape_region_constraints<'gcx, 'tcx, R>(
    infcx: &InferCtxt<'_, 'gcx, 'tcx>,
    op: impl FnOnce() -> Fallible<InferOk<'tcx, R>>,
) -> Fallible<(R, Option<Rc<Vec<QueryRegionConstraint<'tcx>>>>)> {
    let mut fulfill_cx = TraitEngine::new(infcx.tcx);
    let dummy_body_id = ObligationCause::dummy().body_id;
    // During NLL, we expect that nobody will register region
    // obligations **except** as part of a custom type op (and, at the
    // end of each custom type op, we scrape out the region
    // obligations that resulted). So this vector should be empty on
    // entry.
    let pre_obligations = infcx.take_registered_region_obligations();
    assert!(
        pre_obligations.is_empty(),
        "scrape_region_constraints: incoming region obligations = {:#?}",
        pre_obligations,
    );
    let InferOk { value, obligations } = infcx.commit_if_ok(|_| op())?;
    debug_assert!(obligations.iter().all(|o| o.cause.body_id == dummy_body_id));
    fulfill_cx.register_predicate_obligations(infcx, obligations);
    if let Err(e) = fulfill_cx.select_all_or_error(infcx) {
        infcx.tcx.sess.diagnostic().delay_span_bug(
            DUMMY_SP,
            &format!("errors selecting obligation during MIR typeck: {:?}", e),
        );
    }
    let region_obligations = infcx.take_registered_region_obligations();
    let region_constraint_data = infcx.take_and_reset_region_constraints();
    let outlives = query_result::make_query_outlives(
        infcx.tcx,
        region_obligations
            .iter()
            .map(|(_, r_o)| (r_o.sup_type, r_o.sub_region))
            .map(|(ty, r)| (infcx.resolve_type_vars_if_possible(&ty), r)),
        &region_constraint_data,
    );
    if outlives.is_empty() {
        Ok((value, None))
    } else {
        Ok((value, Some(Rc::new(outlives))))
    }
}
fn scrape_region_constraints < ' gcx , ' tcx , R > ( infcx : & InferCtxt < ' _ , ' gcx , ' tcx > , op : impl FnOnce ( ) -> Fallible < InferOk < ' tcx , R > > , ) -> Fallible < ( R , Option < Rc < Vec < QueryRegionConstraint < ' tcx > > > > ) > { let mut fulfill_cx = TraitEngine :: new ( infcx . tcx ) ; let dummy_body_id = ObligationCause :: dummy ( ) . body_id ; // During NLL, we expect that nobody will register region // obligations **except** as part of a custom type op (and, at the // end of each custom type op, we scrape out the region // obligations that resulted). So this vector should be empty on // entry. let pre_obligations = infcx . take_registered_region_obligations ( ) ; assert ! ( pre_obligations is_empty ( ) " " pre_obligations ) ; let InferOk { value , obligations } = infcx . commit_if_ok ( | _ | op ( ) ) ? ; debug_assert ! ( obligations iter ( ) all ( o o cause body_id dummy_body_id ) ) ; fulfill_cx . register_predicate_obligations ( infcx , obligations ) ; if let Err ( e ) = fulfill_cx . select_all_or_error ( infcx ) { infcx . tcx . sess . diagnostic ( ) . delay_span_bug ( DUMMY_SP , & format ! ( " " e ) , ) ; } let region_obligations = infcx . take_registered_region_obligations ( ) ; let region_constraint_data = infcx . take_and_reset_region_constraints ( ) ; let outlives = query_result :: make_query_outlives ( infcx . tcx , region_obligations . iter ( ) . map ( | ( _ , r_o ) | ( r_o . sup_type , r_o . sub_region ) ) . map ( | ( ty , r ) | ( infcx . resolve_type_vars_if_possible ( & ty ) , r ) ) , & region_constraint_data , ) ; if outlives . is_empty ( ) { Ok ( ( value , None ) ) } else { Ok ( ( value , Some ( Rc :: new ( outlives ) ) ) ) } }
Executes `op` and then scrapes out all the "old style" region
constraints that result, creating query-region-constraints.
Executes ` op ` and then scrapes out all the " old style " region constraints that result creating query - region - constraints .
infcx
&InferCtxt<'_, 'gcx, 'tcx>
op
impl FnOnce() -> Fallible<InferOk<'tcx, R>>
infcx
&InferCtxt<'_, 'gcx, 'tcx>
op
impl FnOnce() -> Fallible<InferOk<'tcx, R>>