From 57f92698be7b1e2ee880535d7029f10b9e384815 Mon Sep 17 00:00:00 2001 From: Aditya-PS-05 Date: Fri, 28 Nov 2025 15:15:29 +0530 Subject: [PATCH 1/2] add test for borrow checker ICE with nested generic closures --- tests/ui/issues/issue-143821.rs | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/ui/issues/issue-143821.rs diff --git a/tests/ui/issues/issue-143821.rs b/tests/ui/issues/issue-143821.rs new file mode 100644 index 0000000000000..f0e308da38718 --- /dev/null +++ b/tests/ui/issues/issue-143821.rs @@ -0,0 +1,39 @@ +//@ check-pass +// Regression test for issue https://github.com/rust-lang/rust/issues/143821 +// Tests that we don't ICE when borrow-checking nested closures with generic type parameters +// and late-bound lifetime parameters. + +fn data_(_: &()) -> &T { + loop {} +} + +fn register(f: F) -> IfaceToken +where + T: 'static, + F: FnOnce(&()), +{ + loop {} +} + +fn method_with_cr_async(cb: CB) +where + CB: Fn(), +{ + loop {} +} + +struct IfaceToken(T); + +fn foo() -> IfaceToken { + register::(|b: &()| { + method_with_cr_async(|| { + data_::(&()); + }); + }) +} + +struct A(); + +fn main() { + foo::(); +} From 2b4b02e61345e8247064ee35c8a22bf09386685f Mon Sep 17 00:00:00 2001 From: Aditya-PS-05 Date: Fri, 28 Nov 2025 18:52:18 +0530 Subject: [PATCH 2/2] change test location --- .../nested-closure-with-generic-ice.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{issues/issue-143821.rs => borrowck/nested-closure-with-generic-ice.rs} (100%) diff --git a/tests/ui/issues/issue-143821.rs b/tests/ui/borrowck/nested-closure-with-generic-ice.rs similarity index 100% rename from tests/ui/issues/issue-143821.rs rename to tests/ui/borrowck/nested-closure-with-generic-ice.rs