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