@@ -99,12 +99,6 @@ enum GenericArgPosition {
9999 MethodCall ,
100100}
101101
102- /// Dummy type used for the `Self` of a `TraitRef` created for converting
103- /// a trait object, and which gets removed in `ExistentialTraitRef`.
104- /// This type must not appear anywhere in other converted types.
105- #[ cfg_attr( not( stage0) , allow( usage_of_ty_tykind) ) ]
106- const TRAIT_OBJECT_DUMMY_SELF : ty:: TyKind < ' static > = ty:: Infer ( ty:: FreshTy ( 0 ) ) ;
107-
108102impl < ' o , ' gcx : ' tcx , ' tcx > dyn AstConv < ' gcx , ' tcx > + ' o {
109103 pub fn ast_region_to_region ( & self ,
110104 lifetime : & hir:: Lifetime ,
@@ -596,7 +590,9 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
596590 infer_types,
597591 ) ;
598592
599- let is_object = self_ty. map_or ( false , |ty| ty. sty == TRAIT_OBJECT_DUMMY_SELF ) ;
593+ let is_object = self_ty. map_or ( false , |ty| {
594+ ty. sty == self . tcx ( ) . types . trait_object_dummy_self . sty
595+ } ) ;
600596 let default_needs_object_self = |param : & ty:: GenericParamDef | {
601597 if let GenericParamDefKind :: Type { has_default, .. } = param. kind {
602598 if is_object && has_default {
@@ -957,10 +953,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
957953 }
958954
959955 /// Transform a `PolyTraitRef` into a `PolyExistentialTraitRef` by
960- /// removing the dummy `Self` type (`TRAIT_OBJECT_DUMMY_SELF `).
956+ /// removing the dummy `Self` type (`trait_object_dummy_self `).
961957 fn trait_ref_to_existential ( & self , trait_ref : ty:: TraitRef < ' tcx > )
962958 -> ty:: ExistentialTraitRef < ' tcx > {
963- if trait_ref. self_ty ( ) . sty != TRAIT_OBJECT_DUMMY_SELF {
959+ if trait_ref. self_ty ( ) . sty != self . tcx ( ) . types . trait_object_dummy_self . sty {
964960 bug ! ( "trait_ref_to_existential called on {:?} with non-dummy Self" , trait_ref) ;
965961 }
966962 ty:: ExistentialTraitRef :: erase_self_ty ( self . tcx ( ) , trait_ref)
@@ -981,7 +977,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
981977 }
982978
983979 let mut projection_bounds = Vec :: new ( ) ;
984- let dummy_self = tcx . mk_ty ( TRAIT_OBJECT_DUMMY_SELF ) ;
980+ let dummy_self = self . tcx ( ) . types . trait_object_dummy_self ;
985981 let ( principal, potential_assoc_types) = self . instantiate_poly_trait_ref (
986982 & trait_bounds[ 0 ] ,
987983 dummy_self,
@@ -1031,7 +1027,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
10311027 }
10321028 ty:: Predicate :: Projection ( pred) => {
10331029 // A `Self` within the original bound will be substituted with a
1034- // `TRAIT_OBJECT_DUMMY_SELF `, so check for that.
1030+ // `trait_object_dummy_self `, so check for that.
10351031 let references_self =
10361032 pred. skip_binder ( ) . ty . walk ( ) . any ( |t| t == dummy_self) ;
10371033
@@ -1131,7 +1127,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
11311127 err. emit ( ) ;
11321128 }
11331129
1134- // Erase the `dummy_self` (`TRAIT_OBJECT_DUMMY_SELF `) used above.
1130+ // Erase the `dummy_self` (`trait_object_dummy_self `) used above.
11351131 let existential_principal = principal. map_bound ( |trait_ref| {
11361132 self . trait_ref_to_existential ( trait_ref)
11371133 } ) ;
0 commit comments