Skip to content

Commit

Permalink
Streamline next_*_var* methods.
Browse files Browse the repository at this point in the history
Inline and remove `next_const_var_id`, `next_int_var_id`,
`next_float_var_id`, all of which have a single call site.
  • Loading branch information
nnethercote committed Oct 6, 2024
1 parent deeb0c5 commit 3386530
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,28 +892,16 @@ impl<'tcx> InferCtxt<'tcx> {
ty::Const::new_var(self.tcx, vid)
}

pub fn next_const_var_id(&self, origin: ConstVariableOrigin) -> ConstVid {
self.inner
.borrow_mut()
.const_unification_table()
.new_key(ConstVariableValue::Unknown { origin, universe: self.universe() })
.vid
}

fn next_int_var_id(&self) -> IntVid {
self.inner.borrow_mut().int_unification_table().new_key(ty::IntVarValue::Unknown)
}

pub fn next_int_var(&self) -> Ty<'tcx> {
Ty::new_int_var(self.tcx, self.next_int_var_id())
}

fn next_float_var_id(&self) -> FloatVid {
self.inner.borrow_mut().float_unification_table().new_key(ty::FloatVarValue::Unknown)
let next_int_var_id =
self.inner.borrow_mut().int_unification_table().new_key(ty::IntVarValue::Unknown);
Ty::new_int_var(self.tcx, next_int_var_id)
}

pub fn next_float_var(&self) -> Ty<'tcx> {
Ty::new_float_var(self.tcx, self.next_float_var_id())
let next_float_var_id =
self.inner.borrow_mut().float_unification_table().new_key(ty::FloatVarValue::Unknown);
Ty::new_float_var(self.tcx, next_float_var_id)
}

/// Creates a fresh region variable with the next available index.
Expand Down

0 comments on commit 3386530

Please sign in to comment.