@@ -1544,7 +1544,7 @@ fn check_fn_or_method<'tcx>(
15441544 check_where_clauses ( wfcx, span, def_id) ;
15451545
15461546 check_return_position_impl_trait_in_trait_bounds (
1547- tcx ,
1547+ wfcx ,
15481548 def_id,
15491549 sig. output ( ) ,
15501550 hir_decl. output . span ( ) ,
@@ -1580,13 +1580,14 @@ fn check_fn_or_method<'tcx>(
15801580
15811581/// Basically `check_associated_type_bounds`, but separated for now and should be
15821582/// deduplicated when RPITITs get lowered into real associated items.
1583- #[ tracing:: instrument( level = "trace" , skip( tcx ) ) ]
1583+ #[ tracing:: instrument( level = "trace" , skip( wfcx ) ) ]
15841584fn check_return_position_impl_trait_in_trait_bounds < ' tcx > (
1585- tcx : TyCtxt < ' tcx > ,
1585+ wfcx : & WfCheckingCtxt < ' _ , ' tcx > ,
15861586 fn_def_id : LocalDefId ,
15871587 fn_output : Ty < ' tcx > ,
15881588 span : Span ,
15891589) {
1590+ let tcx = wfcx. tcx ( ) ;
15901591 if let Some ( assoc_item) = tcx. opt_associated_item ( fn_def_id. to_def_id ( ) )
15911592 && assoc_item. container == ty:: AssocItemContainer :: TraitContainer
15921593 {
@@ -1596,22 +1597,20 @@ fn check_return_position_impl_trait_in_trait_bounds<'tcx>(
15961597 && tcx. def_kind ( proj. item_def_id ) == DefKind :: ImplTraitPlaceholder
15971598 && tcx. impl_trait_in_trait_parent ( proj. item_def_id ) == fn_def_id. to_def_id ( )
15981599 {
1599- // Create a new context, since we want the opaque's ParamEnv and not the parent's.
16001600 let span = tcx. def_span ( proj. item_def_id ) ;
1601- enter_wf_checking_ctxt ( tcx, span, proj. item_def_id . expect_local ( ) , |wfcx| {
1602- let bounds = wfcx. tcx ( ) . explicit_item_bounds ( proj. item_def_id ) ;
1603- let wf_obligations = bounds. iter ( ) . flat_map ( |& ( bound, bound_span) | {
1604- let normalized_bound = wfcx. normalize ( span, None , bound) ;
1605- traits:: wf:: predicate_obligations (
1606- wfcx. infcx ,
1607- wfcx. param_env ,
1608- wfcx. body_id ,
1609- normalized_bound,
1610- bound_span,
1611- )
1612- } ) ;
1613- wfcx. register_obligations ( wf_obligations) ;
1601+ let bounds = wfcx. tcx ( ) . explicit_item_bounds ( proj. item_def_id ) ;
1602+ let wf_obligations = bounds. iter ( ) . flat_map ( |& ( bound, bound_span) | {
1603+ let bound = ty:: EarlyBinder ( bound) . subst ( tcx, proj. substs ) ;
1604+ let normalized_bound = wfcx. normalize ( span, None , bound) ;
1605+ traits:: wf:: predicate_obligations (
1606+ wfcx. infcx ,
1607+ wfcx. param_env ,
1608+ wfcx. body_id ,
1609+ normalized_bound,
1610+ bound_span,
1611+ )
16141612 } ) ;
1613+ wfcx. register_obligations ( wf_obligations) ;
16151614 }
16161615 }
16171616 }
0 commit comments