From 699d3e43124c3eae5417bf92ffd032a17b567f95 Mon Sep 17 00:00:00 2001 From: Boxy Uwu Date: Tue, 30 Sep 2025 17:19:53 +0100 Subject: [PATCH 1/2] shallow resolve to root var --- compiler/rustc_infer/src/infer/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index c9fc124d3bf8d..25eb2bf271e9f 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -1125,7 +1125,9 @@ impl<'tcx> InferCtxt<'tcx> { // Note: if these two lines are combined into one we get // dynamic borrow errors on `self.inner`. let known = self.inner.borrow_mut().type_variables().probe(v).known(); - known.map_or(ty, |t| self.shallow_resolve(t)) + known.map_or(Ty::new_var(self.tcx, self.root_var(v)), |t| { + self.shallow_resolve(t) + }) } ty::IntVar(v) => { From d821286b0b41ee054e8589634adddd5b014ae81b Mon Sep 17 00:00:00 2001 From: Boxy Uwu Date: Tue, 30 Sep 2025 17:23:27 +0100 Subject: [PATCH 2/2] test --- tests/ui/coercion/issue-88097.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/ui/coercion/issue-88097.rs b/tests/ui/coercion/issue-88097.rs index f636323d62367..a5804e3b789cb 100644 --- a/tests/ui/coercion/issue-88097.rs +++ b/tests/ui/coercion/issue-88097.rs @@ -3,6 +3,9 @@ // behavior has been fixed. //@ check-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver fn peculiar() -> impl Fn(u8) -> u8 { return |x| x + 1