Add next_int_var and next_float_var
This commit is contained in:
parent
f9d8bb8e2c
commit
fa18c129c3
4 changed files with 16 additions and 10 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue