From 3da461260fb33a4038adf6fd2ee328215b136819 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 22 Jun 2026 16:50:44 +0200 Subject: [PATCH] norm: fix escaping placeholder check --- compiler/rustc_next_trait_solver/src/normalize.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_next_trait_solver/src/normalize.rs b/compiler/rustc_next_trait_solver/src/normalize.rs index 3bf2f64cf8887..675c8be873f0d 100644 --- a/compiler/rustc_next_trait_solver/src/normalize.rs +++ b/compiler/rustc_next_trait_solver/src/normalize.rs @@ -121,24 +121,21 @@ where alias_term: AliasTerm, has_escaping: HasEscapingBoundVars, ) -> Result, NoSolution> { - let current_universe = self.infcx.universe(); - self.infcx.create_next_universe(); - let (normalized, ambig_goal) = (self.normalize)(alias_term)?; // Return ambiguous higher ranked alias as is, if // - it contains escaping vars, and - // - the normalized term contains infer vars newly created - // in the normalization above. - // The problem is that they may be resolved to types - // referencing the temporary placeholders. + // - the normalized term contains infer vars which may mention + // temporary placeholders after we've already mapped them back + // to bound vars. // - // We can normalize the ambiguous alias again after the binder is instantiated. + // We can normalize the ambiguous alias again after the binder is instantiated + // or once we've made further inference progress. if ambig_goal.is_some() && has_escaping == HasEscapingBoundVars::Yes { let mut visitor = MaxUniverse::new(self.infcx); normalized.visit_with(&mut visitor); let max_universe = visitor.max_universe(); - if current_universe.cannot_name(max_universe) { + if max_universe.can_name(self.universes.first().unwrap().unwrap()) { return Ok(None); } }