@@ -74,8 +74,9 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
7474 match (&a.kind, &b.kind) {
7575 // Relate integral variables to other types
7676 (&ty::Infer(ty::IntVar(a_id)), &ty::Infer(ty::IntVar(b_id))) => {
77- self.int_unification_table
77+ self.inner
7878 .borrow_mut()
79+ .int_unification_table
7980 .unify_var_var(a_id, b_id)
8081 .map_err(|e| int_unification_error(a_is_expected, e))?;
8182 Ok(a)
@@ -95,8 +96,9 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
9596
9697 // Relate floating-point variables to other types
9798 (&ty::Infer(ty::FloatVar(a_id)), &ty::Infer(ty::FloatVar(b_id))) => {
98- self.float_unification_table
99+ self.inner
99100 .borrow_mut()
101+ .float_unification_table
100102 .unify_var_var(a_id, b_id)
101103 .map_err(|e| float_unification_error(relation.a_is_expected(), e))?;
102104 Ok(a)
@@ -131,8 +133,8 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
131133 return Ok(a);
132134 }
133135
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);
136138
137139 let a_is_expected = relation.a_is_expected();
138140
@@ -141,8 +143,9 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
141143 ty::ConstKind::Infer(InferConst::Var(a_vid)),
142144 ty::ConstKind::Infer(InferConst::Var(b_vid)),
143145 ) => {
144- self.const_unification_table
146+ self.inner
145147 .borrow_mut()
148+ .const_unification_table
146149 .unify_var_var(a_vid, b_vid)
147150 .map_err(|e| const_unification_error(a_is_expected, e))?;
148151 return Ok(a);
@@ -174,8 +177,9 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
174177 vid: ty::ConstVid<'tcx>,
175178 value: &'tcx ty::Const<'tcx>,
176179 ) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> {
177- self.const_unification_table
180+ self.inner
178181 .borrow_mut()
182+ .const_unification_table
179183 .unify_var_value(
180184 vid,
181185 ConstVarValue {
@@ -196,8 +200,9 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
196200 vid: ty::IntVid,
197201 val: ty::IntVarValue,
198202 ) -> RelateResult<'tcx, Ty<'tcx>> {
199- self.int_unification_table
203+ self.inner
200204 .borrow_mut()
205+ .int_unification_table
201206 .unify_var_value(vid, Some(val))
202207 .map_err(|e| int_unification_error(vid_is_expected, e))?;
203208 match val {
@@ -212,8 +217,9 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
212217 vid: ty::FloatVid,
213218 val: ast::FloatTy,
214219 ) -> RelateResult<'tcx, Ty<'tcx>> {
215- self.float_unification_table
220+ self.inner
216221 .borrow_mut()
222+ .float_unification_table
217223 .unify_var_value(vid, Some(ty::FloatVarValue(val)))
218224 .map_err(|e| float_unification_error(vid_is_expected, e))?;
219225 Ok(self.tcx.mk_mach_float(val))
@@ -260,7 +266,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
260266 use self::RelationDir::*;
261267
262268 // 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());
264270
265271 debug!("instantiate(a_ty={:?} dir={:?} b_vid={:?})", a_ty, dir, b_vid);
266272
@@ -280,7 +286,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
280286 "instantiate(a_ty={:?}, dir={:?}, b_vid={:?}, generalized b_ty={:?})",
281287 a_ty, dir, b_vid, b_ty
282288 );
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);
284290
285291 if needs_wf {
286292 self.obligations.push(Obligation::new(
@@ -338,7 +344,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
338344
339345 debug!("generalize: ambient_variance = {:?}", ambient_variance);
340346
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) {
342348 v @ TypeVariableValue::Known { .. } => {
343349 panic!("instantiating {:?} which has a known value {:?}", for_vid, v,)
344350 }
@@ -350,7 +356,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
350356 let mut generalize = Generalizer {
351357 infcx: self.infcx,
352358 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),
354360 for_universe,
355361 ambient_variance,
356362 needs_wf: false,
@@ -502,17 +508,16 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
502508 // us from creating infinitely sized types.
503509 match t.kind {
504510 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);
508513 if sub_vid == self.for_vid_sub_root {
509514 // If sub-roots are equal, then `for_vid` and
510515 // `vid` are related via subtyping.
511516 Err(TypeError::CyclicTy(self.root_ty))
512517 } else {
513- match variables.probe(vid) {
518+ let probe = self.infcx.inner.borrow_mut().type_variables.probe(vid);
519+ match probe {
514520 TypeVariableValue::Known { value: u } => {
515- drop(variables);
516521 debug!("generalize: known value {:?}", u);
517522 self.relate(&u, &u)
518523 }
@@ -536,8 +541,13 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
536541 ty::Covariant | ty::Contravariant => (),
537542 }
538543
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+ );
541551 let u = self.tcx().mk_ty_var(new_var_id);
542552 debug!("generalize: replacing original vid={:?} with new={:?}", vid, u);
543553 Ok(u)
@@ -612,7 +622,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
612622
613623 match c.val {
614624 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 ;
616626 let var_value = variable_table.probe_value(vid);
617627 match var_value.val {
618628 ConstVariableValue::Known { value: u } => self.relate(&u, &u),
0 commit comments