@@ -1221,25 +1221,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1221
1221
)
1222
1222
}
1223
1223
1224
- /// Transform a `PolyTraitRef` into a `PolyExistentialTraitRef` by
1225
- /// removing the dummy `Self` type (`trait_object_dummy_self`).
1226
- fn trait_ref_to_existential (
1227
- & self ,
1228
- trait_ref : ty:: TraitRef < ' tcx > ,
1229
- ) -> ty:: ExistentialTraitRef < ' tcx > {
1230
- if trait_ref. self_ty ( ) != self . tcx ( ) . types . trait_object_dummy_self {
1231
- // FIXME: There appears to be a missing filter on top of `expand_trait_aliases`, which
1232
- // picks up non-supertraits where clauses - but also, the object safety completely
1233
- // ignores trait aliases, which could be object safety hazards. We `delay_span_bug`
1234
- // here to avoid an ICE in stable even when the feature is disabled. (#66420)
1235
- self . tcx ( ) . sess . delay_span_bug ( DUMMY_SP , & format ! (
1236
- "trait_ref_to_existential called on {:?} with non-dummy Self" ,
1237
- trait_ref,
1238
- ) ) ;
1239
- }
1240
- ty:: ExistentialTraitRef :: erase_self_ty ( self . tcx ( ) , trait_ref)
1241
- }
1242
-
1243
1224
fn conv_object_ty_poly_trait_ref ( & self ,
1244
1225
span : Span ,
1245
1226
trait_bounds : & [ hir:: PolyTraitRef ] ,
@@ -1421,13 +1402,30 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1421
1402
debug ! ( "regular_traits: {:?}" , regular_traits) ;
1422
1403
debug ! ( "auto_traits: {:?}" , auto_traits) ;
1423
1404
1405
+ // Transform a `PolyTraitRef` into a `PolyExistentialTraitRef` by
1406
+ // removing the dummy `Self` type (`trait_object_dummy_self`).
1407
+ let trait_ref_to_existential = |trait_ref : ty:: TraitRef < ' tcx > | {
1408
+ if trait_ref. self_ty ( ) != dummy_self {
1409
+ // FIXME: There appears to be a missing filter on top of `expand_trait_aliases`,
1410
+ // which picks up non-supertraits where clauses - but also, the object safety
1411
+ // completely ignores trait aliases, which could be object safety hazards. We
1412
+ // `delay_span_bug` here to avoid an ICE in stable even when the feature is
1413
+ // disabled. (#66420)
1414
+ tcx. sess . delay_span_bug ( DUMMY_SP , & format ! (
1415
+ "trait_ref_to_existential called on {:?} with non-dummy Self" ,
1416
+ trait_ref,
1417
+ ) ) ;
1418
+ }
1419
+ ty:: ExistentialTraitRef :: erase_self_ty ( tcx, trait_ref)
1420
+ } ;
1421
+
1424
1422
// Erase the `dummy_self` (`trait_object_dummy_self`) used above.
1425
1423
let existential_trait_refs = regular_traits. iter ( ) . map ( |i| {
1426
- i. trait_ref ( ) . map_bound ( |trait_ref| self . trait_ref_to_existential ( trait_ref) )
1424
+ i. trait_ref ( ) . map_bound ( |trait_ref| trait_ref_to_existential ( trait_ref) )
1427
1425
} ) ;
1428
1426
let existential_projections = bounds. projection_bounds . iter ( ) . map ( |( bound, _) | {
1429
1427
bound. map_bound ( |b| {
1430
- let trait_ref = self . trait_ref_to_existential ( b. projection_ty . trait_ref ( tcx) ) ;
1428
+ let trait_ref = trait_ref_to_existential ( b. projection_ty . trait_ref ( tcx) ) ;
1431
1429
ty:: ExistentialProjection {
1432
1430
ty : b. ty ,
1433
1431
item_def_id : b. projection_ty . item_def_id ,
0 commit comments