@@ -1544,7 +1544,7 @@ fn check_fn_or_method<'tcx>(
1544
1544
check_where_clauses ( wfcx, span, def_id) ;
1545
1545
1546
1546
check_return_position_impl_trait_in_trait_bounds (
1547
- tcx ,
1547
+ wfcx ,
1548
1548
def_id,
1549
1549
sig. output ( ) ,
1550
1550
hir_decl. output . span ( ) ,
@@ -1580,13 +1580,14 @@ fn check_fn_or_method<'tcx>(
1580
1580
1581
1581
/// Basically `check_associated_type_bounds`, but separated for now and should be
1582
1582
/// deduplicated when RPITITs get lowered into real associated items.
1583
- #[ tracing:: instrument( level = "trace" , skip( tcx ) ) ]
1583
+ #[ tracing:: instrument( level = "trace" , skip( wfcx ) ) ]
1584
1584
fn check_return_position_impl_trait_in_trait_bounds < ' tcx > (
1585
- tcx : TyCtxt < ' tcx > ,
1585
+ wfcx : & WfCheckingCtxt < ' _ , ' tcx > ,
1586
1586
fn_def_id : LocalDefId ,
1587
1587
fn_output : Ty < ' tcx > ,
1588
1588
span : Span ,
1589
1589
) {
1590
+ let tcx = wfcx. tcx ( ) ;
1590
1591
if let Some ( assoc_item) = tcx. opt_associated_item ( fn_def_id. to_def_id ( ) )
1591
1592
&& assoc_item. container == ty:: AssocItemContainer :: TraitContainer
1592
1593
{
@@ -1596,22 +1597,20 @@ fn check_return_position_impl_trait_in_trait_bounds<'tcx>(
1596
1597
&& tcx. def_kind ( proj. item_def_id ) == DefKind :: ImplTraitPlaceholder
1597
1598
&& tcx. impl_trait_in_trait_parent ( proj. item_def_id ) == fn_def_id. to_def_id ( )
1598
1599
{
1599
- // Create a new context, since we want the opaque's ParamEnv and not the parent's.
1600
1600
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
+ )
1614
1612
} ) ;
1613
+ wfcx. register_obligations ( wf_obligations) ;
1615
1614
}
1616
1615
}
1617
1616
}
0 commit comments