Skip to content

Commit fa18c12

Browse files
committed
Add next_int_var and next_float_var
1 parent f9d8bb8 commit fa18c12

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

src/librustc/infer/canonical/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
360360
)
361361
}
362362

363-
CanonicalTyVarKind::Int => self.tcx.mk_int_var(self.next_int_var_id()),
363+
CanonicalTyVarKind::Int => self.next_int_var(),
364364

365-
CanonicalTyVarKind::Float => self.tcx.mk_float_var(self.next_float_var_id()),
365+
CanonicalTyVarKind::Float => self.next_float_var(),
366366
};
367367
ty.into()
368368
}

src/librustc/infer/fudge.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,14 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for InferenceFudger<'a, 'gcx, 'tcx>
149149
}
150150
ty::Infer(ty::InferTy::IntVar(vid)) => {
151151
if self.int_vars.contains(&vid) {
152-
self.infcx.tcx.mk_int_var(self.infcx.next_int_var_id())
152+
self.infcx.next_int_var()
153153
} else {
154154
ty
155155
}
156156
}
157157
ty::Infer(ty::InferTy::FloatVar(vid)) => {
158158
if self.float_vars.contains(&vid) {
159-
self.infcx.tcx.mk_float_var(self.infcx.next_float_var_id())
159+
self.infcx.next_float_var()
160160
} else {
161161
ty
162162
}

src/librustc/infer/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,14 +999,22 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
999999
self.tcx.mk_ty_var(self.next_ty_var_id(true, origin))
10001000
}
10011001

1002-
pub fn next_int_var_id(&self) -> IntVid {
1002+
fn next_int_var_id(&self) -> IntVid {
10031003
self.int_unification_table.borrow_mut().new_key(None)
10041004
}
10051005

1006-
pub fn next_float_var_id(&self) -> FloatVid {
1006+
pub fn next_int_var(&self) -> Ty<'tcx> {
1007+
self.tcx.mk_int_var(self.next_int_var_id())
1008+
}
1009+
1010+
fn next_float_var_id(&self) -> FloatVid {
10071011
self.float_unification_table.borrow_mut().new_key(None)
10081012
}
10091013

1014+
pub fn next_float_var(&self) -> Ty<'tcx> {
1015+
self.tcx.mk_float_var(self.next_float_var_id())
1016+
}
1017+
10101018
/// Creates a fresh region variable with the next available index.
10111019
/// The variable will be created in the maximum universe created
10121020
/// thus far, allowing it to name any region created thus far.

src/librustc_typeck/check/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3097,8 +3097,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
30973097
_ => None
30983098
}
30993099
});
3100-
opt_ty.unwrap_or_else(
3101-
|| tcx.mk_int_var(self.next_int_var_id()))
3100+
opt_ty.unwrap_or_else(|| self.next_int_var())
31023101
}
31033102
ast::LitKind::Float(_, t) => tcx.mk_mach_float(t),
31043103
ast::LitKind::FloatUnsuffixed(_) => {
@@ -3108,8 +3107,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
31083107
_ => None
31093108
}
31103109
});
3111-
opt_ty.unwrap_or_else(
3112-
|| tcx.mk_float_var(self.next_float_var_id()))
3110+
opt_ty.unwrap_or_else(|| self.next_float_var())
31133111
}
31143112
ast::LitKind::Bool(_) => tcx.types.bool,
31153113
ast::LitKind::Err(_) => tcx.types.err,

0 commit comments

Comments
 (0)