File tree 5 files changed +12
-19
lines changed
rustc_hir_analysis/src/check
rustc_trait_selection/src/traits
5 files changed +12
-19
lines changed Original file line number Diff line number Diff line change @@ -1589,7 +1589,8 @@ fn check_return_position_impl_trait_in_trait_bounds<'tcx>(
1589
1589
if let ty:: GenericArgKind :: Type ( ty) = arg. unpack ( )
1590
1590
&& let ty:: Projection ( proj) = ty. kind ( )
1591
1591
&& tcx. def_kind ( proj. item_def_id ) == DefKind :: ImplTraitPlaceholder
1592
- && tcx. impl_trait_in_trait_parent ( proj. item_def_id ) == fn_def_id. to_def_id ( )
1592
+ && let ( trait_fn_def_id, _) = tcx. def_path ( proj. item_def_id ) . get_impl_trait_in_trait_data ( ) . unwrap ( )
1593
+ && trait_fn_def_id == fn_def_id. to_def_id ( )
1593
1594
{
1594
1595
let bounds = wfcx. tcx ( ) . explicit_item_bounds ( proj. item_def_id ) ;
1595
1596
let wf_obligations = bounds. iter ( ) . flat_map ( |& ( bound, bound_span) | {
Original file line number Diff line number Diff line change @@ -2628,14 +2628,6 @@ impl<'tcx> TyCtxt<'tcx> {
2628
2628
pub fn is_const_default_method ( self , def_id : DefId ) -> bool {
2629
2629
matches ! ( self . trait_of_item( def_id) , Some ( trait_id) if self . has_attr( trait_id, sym:: const_trait) )
2630
2630
}
2631
-
2632
- pub fn impl_trait_in_trait_parent ( self , mut def_id : DefId ) -> DefId {
2633
- while let def_kind = self . def_kind ( def_id) && def_kind != DefKind :: AssocFn {
2634
- debug_assert_eq ! ( def_kind, DefKind :: ImplTraitPlaceholder ) ;
2635
- def_id = self . parent ( def_id) ;
2636
- }
2637
- def_id
2638
- }
2639
2631
}
2640
2632
2641
2633
/// Yields the parent function's `LocalDefId` if `def_id` is an `impl Trait` definition.
Original file line number Diff line number Diff line change @@ -1148,7 +1148,10 @@ impl<'tcx> ProjectionTy<'tcx> {
1148
1148
match tcx. def_kind ( self . item_def_id ) {
1149
1149
DefKind :: AssocTy | DefKind :: AssocConst => tcx. parent ( self . item_def_id ) ,
1150
1150
DefKind :: ImplTraitPlaceholder => {
1151
- tcx. parent ( tcx. impl_trait_in_trait_parent ( self . item_def_id ) )
1151
+ let ( fn_def_id, _) =
1152
+ tcx. def_path ( self . item_def_id ) . get_impl_trait_in_trait_data ( ) . unwrap ( ) ;
1153
+
1154
+ tcx. parent ( fn_def_id)
1152
1155
}
1153
1156
kind => bug ! ( "unexpected DefKind in ProjectionTy: {kind:?}" ) ,
1154
1157
}
Original file line number Diff line number Diff line change @@ -129,7 +129,8 @@ where
129
129
projection. trait_ref_and_own_substs ( tcx)
130
130
} else {
131
131
// HACK(RPITIT): Remove this when RPITITs are lowered to regular assoc tys
132
- let def_id = tcx. impl_trait_in_trait_parent ( projection. item_def_id ) ;
132
+ let ( def_id, _) =
133
+ tcx. def_path ( projection. item_def_id ) . get_impl_trait_in_trait_data ( ) . unwrap ( ) ;
133
134
let trait_generics = tcx. generics_of ( def_id) ;
134
135
(
135
136
ty:: TraitRef { def_id, substs : projection. substs . truncate_to ( tcx, trait_generics) } ,
Original file line number Diff line number Diff line change @@ -1324,13 +1324,8 @@ fn assemble_candidate_for_impl_trait_in_trait<'cx, 'tcx>(
1324
1324
) {
1325
1325
let tcx = selcx. tcx ( ) ;
1326
1326
if tcx. def_kind ( obligation. predicate . item_def_id ) == DefKind :: ImplTraitPlaceholder {
1327
- let trait_fn_def_id = if let Some ( ( fn_def_id, _) ) =
1328
- tcx. def_path ( obligation. predicate . item_def_id ) . get_impl_trait_in_trait_data ( )
1329
- {
1330
- fn_def_id
1331
- } else {
1332
- tcx. impl_trait_in_trait_parent ( obligation. predicate . item_def_id )
1333
- } ;
1327
+ let ( trait_fn_def_id, _) =
1328
+ tcx. def_path ( obligation. predicate . item_def_id ) . get_impl_trait_in_trait_data ( ) . unwrap ( ) ;
1334
1329
// If we are trying to project an RPITIT with trait's default `Self` parameter,
1335
1330
// then we must be within a default trait body.
1336
1331
if obligation. predicate . self_ty ( )
@@ -2238,7 +2233,8 @@ fn confirm_impl_trait_in_trait_candidate<'tcx>(
2238
2233
let tcx = selcx. tcx ( ) ;
2239
2234
let mut obligations = data. nested ;
2240
2235
2241
- let trait_fn_def_id = tcx. impl_trait_in_trait_parent ( obligation. predicate . item_def_id ) ;
2236
+ let ( trait_fn_def_id, _) =
2237
+ tcx. def_path ( obligation. predicate . item_def_id ) . get_impl_trait_in_trait_data ( ) . unwrap ( ) ;
2242
2238
let Ok ( leaf_def) = assoc_def ( selcx, data. impl_def_id , trait_fn_def_id) else {
2243
2239
return Progress { term : tcx. ty_error ( ) . into ( ) , obligations } ;
2244
2240
} ;
You can’t perform that action at this time.
0 commit comments