@@ -27,9 +27,12 @@ use syntax::ast::{self, Name};
27
27
use syntax:: symbol:: InternedString ;
28
28
use syntax_pos:: { Span , DUMMY_SP } ;
29
29
use ty:: fold:: { TypeFoldable , TypeFolder , TypeVisitor } ;
30
- use ty:: subst:: { CanonicalUserSubsts , Subst , Substs } ;
31
- use ty:: { self , AdtDef , CanonicalTy , ClosureSubsts , GeneratorSubsts , Region , Ty , TyCtxt } ;
30
+ use ty:: subst:: { Subst , Substs } ;
32
31
use ty:: layout:: VariantIdx ;
32
+ use ty:: {
33
+ self , AdtDef , CanonicalUserTypeAnnotations , ClosureSubsts , GeneratorSubsts , Region , Ty , TyCtxt ,
34
+ UserTypeAnnotationIndex , UserTypeAnnotation ,
35
+ } ;
33
36
use util:: ppaux;
34
37
35
38
pub use mir:: interpret:: AssertMessage ;
@@ -121,6 +124,9 @@ pub struct Mir<'tcx> {
121
124
/// variables and temporaries.
122
125
pub local_decls : LocalDecls < ' tcx > ,
123
126
127
+ /// User type annotations
128
+ pub user_type_annotations : CanonicalUserTypeAnnotations < ' tcx > ,
129
+
124
130
/// Number of arguments this function takes.
125
131
///
126
132
/// Starting at local 1, `arg_count` locals will be provided by the caller
@@ -161,7 +167,8 @@ impl<'tcx> Mir<'tcx> {
161
167
source_scope_local_data : ClearCrossCrate < IndexVec < SourceScope , SourceScopeLocalData > > ,
162
168
promoted : IndexVec < Promoted , Mir < ' tcx > > ,
163
169
yield_ty : Option < Ty < ' tcx > > ,
164
- local_decls : IndexVec < Local , LocalDecl < ' tcx > > ,
170
+ local_decls : LocalDecls < ' tcx > ,
171
+ user_type_annotations : CanonicalUserTypeAnnotations < ' tcx > ,
165
172
arg_count : usize ,
166
173
upvar_decls : Vec < UpvarDecl > ,
167
174
span : Span ,
@@ -185,6 +192,7 @@ impl<'tcx> Mir<'tcx> {
185
192
generator_drop : None ,
186
193
generator_layout : None ,
187
194
local_decls,
195
+ user_type_annotations,
188
196
arg_count,
189
197
upvar_decls,
190
198
spread_arg : None ,
@@ -418,6 +426,7 @@ impl_stable_hash_for!(struct Mir<'tcx> {
418
426
generator_drop,
419
427
generator_layout,
420
428
local_decls,
429
+ user_type_annotations,
421
430
arg_count,
422
431
upvar_decls,
423
432
spread_arg,
@@ -2232,7 +2241,7 @@ pub enum AggregateKind<'tcx> {
2232
2241
& ' tcx AdtDef ,
2233
2242
VariantIdx ,
2234
2243
& ' tcx Substs < ' tcx > ,
2235
- Option < UserTypeAnnotation < ' tcx > > ,
2244
+ Option < UserTypeAnnotationIndex > ,
2236
2245
Option < usize > ,
2237
2246
) ,
2238
2247
@@ -2446,38 +2455,11 @@ pub struct Constant<'tcx> {
2446
2455
/// indicate that `Vec<_>` was explicitly specified.
2447
2456
///
2448
2457
/// Needed for NLL to impose user-given type constraints.
2449
- pub user_ty : Option < UserTypeAnnotation < ' tcx > > ,
2458
+ pub user_ty : Option < UserTypeAnnotationIndex > ,
2450
2459
2451
2460
pub literal : & ' tcx ty:: Const < ' tcx > ,
2452
2461
}
2453
2462
2454
- /// A user-given type annotation attached to a constant. These arise
2455
- /// from constants that are named via paths, like `Foo::<A>::new` and
2456
- /// so forth.
2457
- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable ) ]
2458
- pub enum UserTypeAnnotation < ' tcx > {
2459
- Ty ( CanonicalTy < ' tcx > ) ,
2460
-
2461
- /// The canonical type is the result of `type_of(def_id)` with the
2462
- /// given substitutions applied.
2463
- TypeOf ( DefId , CanonicalUserSubsts < ' tcx > ) ,
2464
- }
2465
-
2466
- EnumTypeFoldableImpl ! {
2467
- impl <' tcx> TypeFoldable <' tcx> for UserTypeAnnotation <' tcx> {
2468
- ( UserTypeAnnotation :: Ty ) ( ty) ,
2469
- ( UserTypeAnnotation :: TypeOf ) ( def, substs) ,
2470
- }
2471
- }
2472
-
2473
- EnumLiftImpl ! {
2474
- impl <' a, ' tcx> Lift <' tcx> for UserTypeAnnotation <' a> {
2475
- type Lifted = UserTypeAnnotation <' tcx>;
2476
- ( UserTypeAnnotation :: Ty ) ( ty) ,
2477
- ( UserTypeAnnotation :: TypeOf ) ( def, substs) ,
2478
- }
2479
- }
2480
-
2481
2463
/// A collection of projections into user types.
2482
2464
///
2483
2465
/// They are projections because a binding can occur a part of a
@@ -2556,7 +2538,7 @@ impl<'tcx> UserTypeProjections<'tcx> {
2556
2538
/// determined by finding the type of the `.0` field from `T`.
2557
2539
#[ derive( Clone , Debug , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable ) ]
2558
2540
pub struct UserTypeProjection < ' tcx > {
2559
- pub base : UserTypeAnnotation < ' tcx > ,
2541
+ pub base : UserTypeAnnotationIndex ,
2560
2542
pub projs : Vec < ProjectionElem < ' tcx , ( ) , ( ) > > ,
2561
2543
}
2562
2544
@@ -2970,6 +2952,7 @@ CloneTypeFoldableAndLiftImpls! {
2970
2952
SourceScope ,
2971
2953
SourceScopeData ,
2972
2954
SourceScopeLocalData ,
2955
+ UserTypeAnnotationIndex ,
2973
2956
}
2974
2957
2975
2958
BraceStructTypeFoldableImpl ! {
@@ -2983,6 +2966,7 @@ BraceStructTypeFoldableImpl! {
2983
2966
generator_drop,
2984
2967
generator_layout,
2985
2968
local_decls,
2969
+ user_type_annotations,
2986
2970
arg_count,
2987
2971
upvar_decls,
2988
2972
spread_arg,
0 commit comments