9
9
// except according to those terms.
10
10
11
11
use self :: TypeVariableValue :: * ;
12
- use hir:: def_id:: { DefId } ;
13
12
use syntax:: ast;
14
13
use syntax_pos:: Span ;
15
14
use ty:: { self , Ty } ;
@@ -82,20 +81,7 @@ enum TypeVariableValue<'tcx> {
82
81
Known {
83
82
value : Ty < ' tcx >
84
83
} ,
85
- Bounded {
86
- default : Option < Default < ' tcx > >
87
- }
88
- }
89
-
90
- // We will use this to store the required information to recapitulate what happened when
91
- // an error occurs.
92
- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
93
- pub struct Default < ' tcx > {
94
- pub ty : Ty < ' tcx > ,
95
- /// The span where the default was incurred
96
- pub origin_span : Span ,
97
- /// The definition that the default originates from
98
- pub def_id : DefId
84
+ Unknown ,
99
85
}
100
86
101
87
pub struct Snapshot {
@@ -104,9 +90,8 @@ pub struct Snapshot {
104
90
sub_snapshot : ut:: Snapshot < ty:: TyVid > ,
105
91
}
106
92
107
- struct Instantiate < ' tcx > {
93
+ struct Instantiate {
108
94
vid : ty:: TyVid ,
109
- default : Option < Default < ' tcx > > ,
110
95
}
111
96
112
97
struct Delegate < ' tcx > ( PhantomData < & ' tcx ( ) > ) ;
@@ -120,13 +105,6 @@ impl<'tcx> TypeVariableTable<'tcx> {
120
105
}
121
106
}
122
107
123
- pub fn default ( & self , vid : ty:: TyVid ) -> Option < Default < ' tcx > > {
124
- match & self . values . get ( vid. index as usize ) . value {
125
- & Known { .. } => None ,
126
- & Bounded { default, .. } => default,
127
- }
128
- }
129
-
130
108
pub fn var_diverges < ' a > ( & ' a self , vid : ty:: TyVid ) -> bool {
131
109
self . values . get ( vid. index as usize ) . diverging
132
110
}
@@ -167,8 +145,8 @@ impl<'tcx> TypeVariableTable<'tcx> {
167
145
} ;
168
146
169
147
match old_value {
170
- TypeVariableValue :: Bounded { default } => {
171
- self . values . record ( Instantiate { vid : vid, default : default } ) ;
148
+ TypeVariableValue :: Unknown => {
149
+ self . values . record ( Instantiate { vid : vid } ) ;
172
150
}
173
151
TypeVariableValue :: Known { value : old_ty } => {
174
152
bug ! ( "instantiating type variable `{:?}` twice: new-value = {:?}, old-value={:?}" ,
@@ -179,13 +157,13 @@ impl<'tcx> TypeVariableTable<'tcx> {
179
157
180
158
pub fn new_var ( & mut self ,
181
159
diverging : bool ,
182
- origin : TypeVariableOrigin ,
183
- default : Option < Default < ' tcx > > , ) -> ty:: TyVid {
160
+ origin : TypeVariableOrigin )
161
+ -> ty:: TyVid {
184
162
debug ! ( "new_var(diverging={:?}, origin={:?})" , diverging, origin) ;
185
163
self . eq_relations . new_key ( ( ) ) ;
186
164
self . sub_relations . new_key ( ( ) ) ;
187
165
let index = self . values . push ( TypeVariableData {
188
- value : Bounded { default } ,
166
+ value : Unknown ,
189
167
origin,
190
168
diverging,
191
169
} ) ;
@@ -237,7 +215,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
237
215
pub fn probe_root ( & mut self , vid : ty:: TyVid ) -> Option < Ty < ' tcx > > {
238
216
debug_assert ! ( self . root_var( vid) == vid) ;
239
217
match self . values . get ( vid. index as usize ) . value {
240
- Bounded { .. } => None ,
218
+ Unknown => None ,
241
219
Known { value } => Some ( value)
242
220
}
243
221
}
@@ -338,7 +316,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
338
316
// quick check to see if this variable was
339
317
// created since the snapshot started or not.
340
318
let escaping_type = match self . values . get ( vid. index as usize ) . value {
341
- Bounded { .. } => bug ! ( ) ,
319
+ Unknown => bug ! ( ) ,
342
320
Known { value } => value,
343
321
} ;
344
322
escaping_types. push ( escaping_type) ;
@@ -369,12 +347,10 @@ impl<'tcx> TypeVariableTable<'tcx> {
369
347
370
348
impl < ' tcx > sv:: SnapshotVecDelegate for Delegate < ' tcx > {
371
349
type Value = TypeVariableData < ' tcx > ;
372
- type Undo = Instantiate < ' tcx > ;
350
+ type Undo = Instantiate ;
373
351
374
- fn reverse ( values : & mut Vec < TypeVariableData < ' tcx > > , action : Instantiate < ' tcx > ) {
375
- let Instantiate { vid, default } = action;
376
- values[ vid. index as usize ] . value = Bounded {
377
- default,
378
- } ;
352
+ fn reverse ( values : & mut Vec < TypeVariableData < ' tcx > > , action : Instantiate ) {
353
+ let Instantiate { vid } = action;
354
+ values[ vid. index as usize ] . value = Unknown ;
379
355
}
380
356
}
0 commit comments