@@ -74,8 +74,9 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
74
74
match ( & a. kind , & b. kind ) {
75
75
// Relate integral variables to other types
76
76
( & ty:: Infer ( ty:: IntVar ( a_id) ) , & ty:: Infer ( ty:: IntVar ( b_id) ) ) => {
77
- self . int_unification_table
77
+ self . inner
78
78
. borrow_mut ( )
79
+ . int_unification_table
79
80
. unify_var_var ( a_id, b_id)
80
81
. map_err ( |e| int_unification_error ( a_is_expected, e) ) ?;
81
82
Ok ( a)
@@ -95,8 +96,9 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
95
96
96
97
// Relate floating-point variables to other types
97
98
( & ty:: Infer ( ty:: FloatVar ( a_id) ) , & ty:: Infer ( ty:: FloatVar ( b_id) ) ) => {
98
- self . float_unification_table
99
+ self . inner
99
100
. borrow_mut ( )
101
+ . float_unification_table
100
102
. unify_var_var ( a_id, b_id)
101
103
. map_err ( |e| float_unification_error ( relation. a_is_expected ( ) , e) ) ?;
102
104
Ok ( a)
@@ -131,8 +133,8 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
131
133
return Ok ( a) ;
132
134
}
133
135
134
- let a = replace_if_possible ( self . const_unification_table . borrow_mut ( ) , a) ;
135
- let b = replace_if_possible ( self . const_unification_table . borrow_mut ( ) , b) ;
136
+ let a = replace_if_possible ( & mut self . inner . borrow_mut ( ) . const_unification_table , a) ;
137
+ let b = replace_if_possible ( & mut self . inner . borrow_mut ( ) . const_unification_table , b) ;
136
138
137
139
let a_is_expected = relation. a_is_expected ( ) ;
138
140
@@ -141,8 +143,9 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
141
143
ty:: ConstKind :: Infer ( InferConst :: Var ( a_vid) ) ,
142
144
ty:: ConstKind :: Infer ( InferConst :: Var ( b_vid) ) ,
143
145
) => {
144
- self . const_unification_table
146
+ self . inner
145
147
. borrow_mut ( )
148
+ . const_unification_table
146
149
. unify_var_var ( a_vid, b_vid)
147
150
. map_err ( |e| const_unification_error ( a_is_expected, e) ) ?;
148
151
return Ok ( a) ;
@@ -174,8 +177,9 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
174
177
vid : ty:: ConstVid < ' tcx > ,
175
178
value : & ' tcx ty:: Const < ' tcx > ,
176
179
) -> RelateResult < ' tcx , & ' tcx ty:: Const < ' tcx > > {
177
- self . const_unification_table
180
+ self . inner
178
181
. borrow_mut ( )
182
+ . const_unification_table
179
183
. unify_var_value (
180
184
vid,
181
185
ConstVarValue {
@@ -196,8 +200,9 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
196
200
vid : ty:: IntVid ,
197
201
val : ty:: IntVarValue ,
198
202
) -> RelateResult < ' tcx , Ty < ' tcx > > {
199
- self . int_unification_table
203
+ self . inner
200
204
. borrow_mut ( )
205
+ . int_unification_table
201
206
. unify_var_value ( vid, Some ( val) )
202
207
. map_err ( |e| int_unification_error ( vid_is_expected, e) ) ?;
203
208
match val {
@@ -212,8 +217,9 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
212
217
vid : ty:: FloatVid ,
213
218
val : ast:: FloatTy ,
214
219
) -> RelateResult < ' tcx , Ty < ' tcx > > {
215
- self . float_unification_table
220
+ self . inner
216
221
. borrow_mut ( )
222
+ . float_unification_table
217
223
. unify_var_value ( vid, Some ( ty:: FloatVarValue ( val) ) )
218
224
. map_err ( |e| float_unification_error ( vid_is_expected, e) ) ?;
219
225
Ok ( self . tcx . mk_mach_float ( val) )
@@ -260,7 +266,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
260
266
use self :: RelationDir :: * ;
261
267
262
268
// Get the actual variable that b_vid has been inferred to
263
- debug_assert ! ( self . infcx. type_variables . borrow_mut( ) . probe( b_vid) . is_unknown( ) ) ;
269
+ debug_assert ! ( self . infcx. inner . borrow_mut( ) . type_variables . probe( b_vid) . is_unknown( ) ) ;
264
270
265
271
debug ! ( "instantiate(a_ty={:?} dir={:?} b_vid={:?})" , a_ty, dir, b_vid) ;
266
272
@@ -280,7 +286,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
280
286
"instantiate(a_ty={:?}, dir={:?}, b_vid={:?}, generalized b_ty={:?})" ,
281
287
a_ty, dir, b_vid, b_ty
282
288
) ;
283
- self . infcx . type_variables . borrow_mut ( ) . instantiate ( b_vid, b_ty) ;
289
+ self . infcx . inner . borrow_mut ( ) . type_variables . instantiate ( b_vid, b_ty) ;
284
290
285
291
if needs_wf {
286
292
self . obligations . push ( Obligation :: new (
@@ -338,7 +344,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
338
344
339
345
debug ! ( "generalize: ambient_variance = {:?}" , ambient_variance) ;
340
346
341
- let for_universe = match self . infcx . type_variables . borrow_mut ( ) . probe ( for_vid) {
347
+ let for_universe = match self . infcx . inner . borrow_mut ( ) . type_variables . probe ( for_vid) {
342
348
v @ TypeVariableValue :: Known { .. } => {
343
349
panic ! ( "instantiating {:?} which has a known value {:?}" , for_vid, v, )
344
350
}
@@ -350,7 +356,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
350
356
let mut generalize = Generalizer {
351
357
infcx : self . infcx ,
352
358
span : self . trace . cause . span ,
353
- for_vid_sub_root : self . infcx . type_variables . borrow_mut ( ) . sub_root_var ( for_vid) ,
359
+ for_vid_sub_root : self . infcx . inner . borrow_mut ( ) . type_variables . sub_root_var ( for_vid) ,
354
360
for_universe,
355
361
ambient_variance,
356
362
needs_wf : false ,
@@ -502,17 +508,16 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
502
508
// us from creating infinitely sized types.
503
509
match t. kind {
504
510
ty:: Infer ( ty:: TyVar ( vid) ) => {
505
- let mut variables = self . infcx . type_variables . borrow_mut ( ) ;
506
- let vid = variables. root_var ( vid) ;
507
- let sub_vid = variables. sub_root_var ( vid) ;
511
+ let vid = self . infcx . inner . borrow_mut ( ) . type_variables . root_var ( vid) ;
512
+ let sub_vid = self . infcx . inner . borrow_mut ( ) . type_variables . sub_root_var ( vid) ;
508
513
if sub_vid == self . for_vid_sub_root {
509
514
// If sub-roots are equal, then `for_vid` and
510
515
// `vid` are related via subtyping.
511
516
Err ( TypeError :: CyclicTy ( self . root_ty ) )
512
517
} else {
513
- match variables. probe ( vid) {
518
+ let probe = self . infcx . inner . borrow_mut ( ) . type_variables . probe ( vid) ;
519
+ match probe {
514
520
TypeVariableValue :: Known { value : u } => {
515
- drop ( variables) ;
516
521
debug ! ( "generalize: known value {:?}" , u) ;
517
522
self . relate ( & u, & u)
518
523
}
@@ -536,8 +541,13 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
536
541
ty:: Covariant | ty:: Contravariant => ( ) ,
537
542
}
538
543
539
- let origin = * variables. var_origin ( vid) ;
540
- let new_var_id = variables. new_var ( self . for_universe , false , origin) ;
544
+ let origin =
545
+ * self . infcx . inner . borrow_mut ( ) . type_variables . var_origin ( vid) ;
546
+ let new_var_id = self . infcx . inner . borrow_mut ( ) . type_variables . new_var (
547
+ self . for_universe ,
548
+ false ,
549
+ origin,
550
+ ) ;
541
551
let u = self . tcx ( ) . mk_ty_var ( new_var_id) ;
542
552
debug ! ( "generalize: replacing original vid={:?} with new={:?}" , vid, u) ;
543
553
Ok ( u)
@@ -612,7 +622,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
612
622
613
623
match c. val {
614
624
ty:: ConstKind :: Infer ( InferConst :: Var ( vid) ) => {
615
- let mut variable_table = self . infcx . const_unification_table . borrow_mut ( ) ;
625
+ let variable_table = & mut self . infcx . inner . borrow_mut ( ) . const_unification_table ;
616
626
let var_value = variable_table. probe_value ( vid) ;
617
627
match var_value. val {
618
628
ConstVariableValue :: Known { value : u } => self . relate ( & u, & u) ,
0 commit comments