Skip to content

Commit 57f9269

Browse files
committed
add test for borrow checker ICE with nested generic closures
1 parent 88bd39b commit 57f9269

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/ui/issues/issue-143821.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//@ check-pass
2+
// Regression test for issue https://github.com/rust-lang/rust/issues/143821
3+
// Tests that we don't ICE when borrow-checking nested closures with generic type parameters
4+
// and late-bound lifetime parameters.
5+
6+
fn data_<T: 'static>(_: &()) -> &T {
7+
loop {}
8+
}
9+
10+
fn register<T, F>(f: F) -> IfaceToken<T>
11+
where
12+
T: 'static,
13+
F: FnOnce(&()),
14+
{
15+
loop {}
16+
}
17+
18+
fn method_with_cr_async<CB>(cb: CB)
19+
where
20+
CB: Fn(),
21+
{
22+
loop {}
23+
}
24+
25+
struct IfaceToken<T: 'static>(T);
26+
27+
fn foo<T>() -> IfaceToken<T> {
28+
register::<T, _>(|b: &()| {
29+
method_with_cr_async(|| {
30+
data_::<T>(&());
31+
});
32+
})
33+
}
34+
35+
struct A();
36+
37+
fn main() {
38+
foo::<A>();
39+
}

0 commit comments

Comments
 (0)