about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-03-21 13:47:57 +0000
committervarkor <github@varkor.com>2019-03-27 09:44:55 +0000
commitfa18c129c3cbb1ef9f731da126a3b2fdcfbd03a6 (patch)
tree4b45df905dd06e7d516a88946880faf79584ff36
parentf9d8bb8e2cb9a8ce7f8663c0a114cbc1a81209d4 (diff)
downloadrust-fa18c129c3cbb1ef9f731da126a3b2fdcfbd03a6.tar.gz
rust-fa18c129c3cbb1ef9f731da126a3b2fdcfbd03a6.zip
Add `next_int_var` and `next_float_var`
-rw-r--r--src/librustc/infer/canonical/mod.rs4
-rw-r--r--src/librustc/infer/fudge.rs4
-rw-r--r--src/librustc/infer/mod.rs12
-rw-r--r--src/librustc_typeck/check/mod.rs6
4 files changed, 16 insertions, 10 deletions
diff --git a/src/librustc/infer/canonical/mod.rs b/src/librustc/infer/canonical/mod.rs
index 95fdd6f01e2..39b84fabff6 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 f21fb603cb5..ba9100bc4f7 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 cc1c439f3bd..16140d006bf 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 c0a869d99b9..7a554605232 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,