@@ -99,12 +99,6 @@ enum GenericArgPosition {
99
99
MethodCall ,
100
100
}
101
101
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
-
108
102
impl < ' o , ' gcx : ' tcx , ' tcx > dyn AstConv < ' gcx , ' tcx > + ' o {
109
103
pub fn ast_region_to_region ( & self ,
110
104
lifetime : & hir:: Lifetime ,
@@ -596,7 +590,9 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
596
590
infer_types,
597
591
) ;
598
592
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
+ } ) ;
600
596
let default_needs_object_self = |param : & ty:: GenericParamDef | {
601
597
if let GenericParamDefKind :: Type { has_default, .. } = param. kind {
602
598
if is_object && has_default {
@@ -957,10 +953,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
957
953
}
958
954
959
955
/// 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 `).
961
957
fn trait_ref_to_existential ( & self , trait_ref : ty:: TraitRef < ' tcx > )
962
958
-> 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 {
964
960
bug ! ( "trait_ref_to_existential called on {:?} with non-dummy Self" , trait_ref) ;
965
961
}
966
962
ty:: ExistentialTraitRef :: erase_self_ty ( self . tcx ( ) , trait_ref)
@@ -981,7 +977,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
981
977
}
982
978
983
979
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 ;
985
981
let ( principal, potential_assoc_types) = self . instantiate_poly_trait_ref (
986
982
& trait_bounds[ 0 ] ,
987
983
dummy_self,
@@ -1031,7 +1027,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
1031
1027
}
1032
1028
ty:: Predicate :: Projection ( pred) => {
1033
1029
// 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.
1035
1031
let references_self =
1036
1032
pred. skip_binder ( ) . ty . walk ( ) . any ( |t| t == dummy_self) ;
1037
1033
@@ -1131,7 +1127,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
1131
1127
err. emit ( ) ;
1132
1128
}
1133
1129
1134
- // Erase the `dummy_self` (`TRAIT_OBJECT_DUMMY_SELF `) used above.
1130
+ // Erase the `dummy_self` (`trait_object_dummy_self `) used above.
1135
1131
let existential_principal = principal. map_bound ( |trait_ref| {
1136
1132
self . trait_ref_to_existential ( trait_ref)
1137
1133
} ) ;
0 commit comments