Remove InferCtxt::freshener.

I have always found this confusingly named, because it creates a new
freshener rather than returning an existing one. We can remove it and
just use `TypeFreshener::new()` at the two call sites, avoiding this
confusion.
This commit is contained in:
Nicholas Nethercote 2025-12-22 17:48:37 +11:00
parent 4652295a3e
commit 1bb9ff05c0
2 changed files with 2 additions and 6 deletions

View file

@ -638,7 +638,7 @@ impl<'tcx> InferCtxt<'tcx> {
}
pub fn freshen<T: TypeFoldable<TyCtxt<'tcx>>>(&self, t: T) -> T {
t.fold_with(&mut self.freshener())
t.fold_with(&mut TypeFreshener::new(self))
}
/// Returns the origin of the type variable identified by `vid`.
@ -658,10 +658,6 @@ impl<'tcx> InferCtxt<'tcx> {
}
}
pub fn freshener<'b>(&'b self) -> TypeFreshener<'b, 'tcx> {
freshen::TypeFreshener::new(self)
}
pub fn unresolved_variables(&self) -> Vec<Ty<'tcx>> {
let mut inner = self.inner.borrow_mut();
let mut vars: Vec<Ty<'_>> = inner

View file

@ -195,7 +195,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
pub fn new(infcx: &'cx InferCtxt<'tcx>) -> SelectionContext<'cx, 'tcx> {
SelectionContext {
infcx,
freshener: infcx.freshener(),
freshener: TypeFreshener::new(infcx),
intercrate_ambiguity_causes: None,
query_mode: TraitQueryMode::Standard,
}