From 74fa6b994ab24b5653d5dd9b97b8b536128df996 Mon Sep 17 00:00:00 2001 From: Amirhossein Akhlaghpour Date: Sun, 5 Jul 2026 19:37:56 +0330 Subject: [PATCH] chore: add regression test for late-bound type method probe ICE Signed-off-by: Amirhossein Akhlaghpour --- .../ui/traits/late-bound-type-method-probe.rs | 19 +++++++++++++++++++ .../late-bound-type-method-probe.stderr | 17 +++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/ui/traits/late-bound-type-method-probe.rs create mode 100644 tests/ui/traits/late-bound-type-method-probe.stderr diff --git a/tests/ui/traits/late-bound-type-method-probe.rs b/tests/ui/traits/late-bound-type-method-probe.rs new file mode 100644 index 0000000000000..ed6b3d866d7a2 --- /dev/null +++ b/tests/ui/traits/late-bound-type-method-probe.rs @@ -0,0 +1,19 @@ +// A method probe involving a late-bound type parameter should report normal +// diagnostics instead of ICEing while structurally normalizing obligations. + +#![feature(non_lifetime_binders)] +#![allow(incomplete_features)] + +pub trait T { + fn t(&self, _: F) {} + //~^ ERROR cannot find type `F` in this scope +} + +pub fn crash(v: &V) +where + for F: T + 'static, +{ + v.t(|| {}); +} + +fn main() {} diff --git a/tests/ui/traits/late-bound-type-method-probe.stderr b/tests/ui/traits/late-bound-type-method-probe.stderr new file mode 100644 index 0000000000000..0ddeb301d5e03 --- /dev/null +++ b/tests/ui/traits/late-bound-type-method-probe.stderr @@ -0,0 +1,17 @@ +error[E0425]: cannot find type `F` in this scope + --> $DIR/late-bound-type-method-probe.rs:8:26 + | +LL | fn t(&self, _: F) {} + | ^ + | + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + | + = note: similarly named trait `Fn` defined here +help: a trait with a similar name exists + | +LL | fn t(&self, _: Fn) {} + | + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0425`.