diff --git a/src/librustc/infer/canonical/mod.rs b/src/librustc/infer/canonical/mod.rs index 95fdd6f01e2a..39b84fabff6f 100644 --- a/src/librustc/infer/canonical/mod.rs +++ b/src/librustc/infer/canonical/mod.rs @@ -360,9 +360,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { ) } - CanonicalTyVarKind::Int => self.tcx.mk_int_var(self.next_int_var_id()), + CanonicalTyVarKind::Int => self.next_int_var(), - CanonicalTyVarKind::Float => self.tcx.mk_float_var(self.next_float_var_id()), + CanonicalTyVarKind::Float => self.next_float_var(), }; ty.into() } diff --git a/src/librustc/infer/fudge.rs b/src/librustc/infer/fudge.rs index f21fb603cb59..ba9100bc4f7a 100644 --- a/src/librustc/infer/fudge.rs +++ b/src/librustc/infer/fudge.rs @@ -149,14 +149,14 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for InferenceFudger<'a, 'gcx, 'tcx> } ty::Infer(ty::InferTy::IntVar(vid)) => { if self.int_vars.contains(&vid) { - self.infcx.tcx.mk_int_var(self.infcx.next_int_var_id()) + self.infcx.next_int_var() } else { ty } } ty::Infer(ty::InferTy::FloatVar(vid)) => { if self.float_vars.contains(&vid) { - self.infcx.tcx.mk_float_var(self.infcx.next_float_var_id()) + self.infcx.next_float_var() } else { ty } diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index cc1c439f3bd9..16140d006bf0 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -999,14 +999,22 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { self.tcx.mk_ty_var(self.next_ty_var_id(true, origin)) } - pub fn next_int_var_id(&self) -> IntVid { + fn next_int_var_id(&self) -> IntVid { self.int_unification_table.borrow_mut().new_key(None) } - pub fn next_float_var_id(&self) -> FloatVid { + pub fn next_int_var(&self) -> Ty<'tcx> { + self.tcx.mk_int_var(self.next_int_var_id()) + } + + fn next_float_var_id(&self) -> FloatVid { self.float_unification_table.borrow_mut().new_key(None) } + pub fn next_float_var(&self) -> Ty<'tcx> { + self.tcx.mk_float_var(self.next_float_var_id()) + } + /// Creates a fresh region variable with the next available index. /// The variable will be created in the maximum universe created /// thus far, allowing it to name any region created thus far. diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index c0a869d99b9d..7a554605232c 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3097,8 +3097,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { _ => None } }); - opt_ty.unwrap_or_else( - || tcx.mk_int_var(self.next_int_var_id())) + opt_ty.unwrap_or_else(|| self.next_int_var()) } ast::LitKind::Float(_, t) => tcx.mk_mach_float(t), ast::LitKind::FloatUnsuffixed(_) => { @@ -3108,8 +3107,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { _ => None } }); - opt_ty.unwrap_or_else( - || tcx.mk_float_var(self.next_float_var_id())) + opt_ty.unwrap_or_else(|| self.next_float_var()) } ast::LitKind::Bool(_) => tcx.types.bool, ast::LitKind::Err(_) => tcx.types.err,