Rollup merge of #149413 - Aditya-PS-05:test-issue-143821-nested-closure-ice, r=JonathanBrouwer

add test for issue 143821

closes rust-lang/rust#143821
This commit is contained in:
Matthias Krüger 2025-11-28 15:19:17 +01:00 committed by GitHub
commit 60e46fbbe3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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: 'static>(_: &()) -> &T {
loop {}
}
fn register<T, F>(f: F) -> IfaceToken<T>
where
T: 'static,
F: FnOnce(&()),
{
loop {}
}
fn method_with_cr_async<CB>(cb: CB)
where
CB: Fn(),
{
loop {}
}
struct IfaceToken<T: 'static>(T);
fn foo<T>() -> IfaceToken<T> {
register::<T, _>(|b: &()| {
method_with_cr_async(|| {
data_::<T>(&());
});
})
}
struct A();
fn main() {
foo::<A>();
}