From 1bb9ff05c077756e77bcce2d34cab5b079bb4012 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 22 Dec 2025 17:48:37 +1100 Subject: [PATCH] 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. --- compiler/rustc_infer/src/infer/mod.rs | 6 +----- compiler/rustc_trait_selection/src/traits/select/mod.rs | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 53567c6071e3..571d5117bc91 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -638,7 +638,7 @@ pub fn typing_mode(&self) -> TypingMode<'tcx> { } pub fn freshen>>(&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 @@ pub fn const_var_origin(&self, vid: ConstVid) -> Option { } } - pub fn freshener<'b>(&'b self) -> TypeFreshener<'b, 'tcx> { - freshen::TypeFreshener::new(self) - } - pub fn unresolved_variables(&self) -> Vec> { let mut inner = self.inner.borrow_mut(); let mut vars: Vec> = inner diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index ea903bac9d61..43f9d6249771 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -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, }