@@ -87,11 +87,7 @@ pub struct TypeVariableStorage<'tcx> {
87
87
}
88
88
89
89
pub struct TypeVariableTable < ' a , ' tcx > {
90
- values : & ' a mut sv:: SnapshotVecStorage < Delegate > ,
91
-
92
- eq_relations : & ' a mut ut:: UnificationTableStorage < TyVidEqKey < ' tcx > > ,
93
-
94
- sub_relations : & ' a mut ut:: UnificationTableStorage < ty:: TyVid > ,
90
+ storage : & ' a mut TypeVariableStorage < ' tcx > ,
95
91
96
92
undo_log : & ' a mut InferCtxtUndoLogs < ' tcx > ,
97
93
}
@@ -165,12 +161,12 @@ impl<'tcx> TypeVariableStorage<'tcx> {
165
161
}
166
162
}
167
163
164
+ #[ inline]
168
165
pub ( crate ) fn with_log < ' a > (
169
166
& ' a mut self ,
170
167
undo_log : & ' a mut InferCtxtUndoLogs < ' tcx > ,
171
168
) -> TypeVariableTable < ' a , ' tcx > {
172
- let TypeVariableStorage { values, eq_relations, sub_relations } = self ;
173
- TypeVariableTable { values, eq_relations, sub_relations, undo_log }
169
+ TypeVariableTable { storage : self , undo_log }
174
170
}
175
171
}
176
172
@@ -180,15 +176,15 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
180
176
/// Note that this function does not return care whether
181
177
/// `vid` has been unified with something else or not.
182
178
pub fn var_diverges ( & self , vid : ty:: TyVid ) -> bool {
183
- self . values . get ( vid. index as usize ) . diverging
179
+ self . storage . values . get ( vid. index as usize ) . diverging
184
180
}
185
181
186
182
/// Returns the origin that was given when `vid` was created.
187
183
///
188
184
/// Note that this function does not return care whether
189
185
/// `vid` has been unified with something else or not.
190
186
pub fn var_origin ( & self , vid : ty:: TyVid ) -> & TypeVariableOrigin {
191
- & self . values . get ( vid. index as usize ) . origin
187
+ & self . storage . values . get ( vid. index as usize ) . origin
192
188
}
193
189
194
190
/// Records that `a == b`, depending on `dir`.
@@ -265,7 +261,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
265
261
266
262
/// Returns the number of type variables created thus far.
267
263
pub fn num_vars ( & self ) -> usize {
268
- self . values . len ( )
264
+ self . storage . values . len ( )
269
265
}
270
266
271
267
/// Returns the "root" variable of `vid` in the `eq_relations`
@@ -319,18 +315,21 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
319
315
}
320
316
}
321
317
318
+ #[ inline]
322
319
fn values (
323
320
& mut self ,
324
321
) -> sv:: SnapshotVec < Delegate , & mut Vec < TypeVariableData > , & mut InferCtxtUndoLogs < ' tcx > > {
325
- self . values . with_log ( self . undo_log )
322
+ self . storage . values . with_log ( self . undo_log )
326
323
}
327
324
325
+ #[ inline]
328
326
fn eq_relations ( & mut self ) -> super :: UnificationTable < ' _ , ' tcx , TyVidEqKey < ' tcx > > {
329
- self . eq_relations . with_log ( self . undo_log )
327
+ self . storage . eq_relations . with_log ( self . undo_log )
330
328
}
331
329
330
+ #[ inline]
332
331
fn sub_relations ( & mut self ) -> super :: UnificationTable < ' _ , ' tcx , ty:: TyVid > {
333
- self . sub_relations . with_log ( self . undo_log )
332
+ self . storage . sub_relations . with_log ( self . undo_log )
334
333
}
335
334
336
335
/// Returns a range of the type variables created during the snapshot.
@@ -342,7 +341,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
342
341
(
343
342
range. start ..range. end ,
344
343
( range. start . index ..range. end . index )
345
- . map ( |index| self . values . get ( index as usize ) . origin )
344
+ . map ( |index| self . storage . values . get ( index as usize ) . origin )
346
345
. collect ( ) ,
347
346
)
348
347
}
@@ -378,7 +377,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
378
377
// quick check to see if this variable was
379
378
// created since the snapshot started or not.
380
379
let mut eq_relations = ut:: UnificationTable :: with_log (
381
- & mut * self . eq_relations ,
380
+ & mut self . storage . eq_relations ,
382
381
& mut * self . undo_log ,
383
382
) ;
384
383
let escaping_type = match eq_relations. probe_value ( vid) {
@@ -400,7 +399,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
400
399
/// Returns indices of all variables that are not yet
401
400
/// instantiated.
402
401
pub fn unsolved_variables ( & mut self ) -> Vec < ty:: TyVid > {
403
- ( 0 ..self . values . len ( ) )
402
+ ( 0 ..self . storage . values . len ( ) )
404
403
. filter_map ( |i| {
405
404
let vid = ty:: TyVid { index : i as u32 } ;
406
405
match self . probe ( vid) {
0 commit comments