Skip to content

Commit 60e46fb

Browse files
authored
Rollup merge of #149413 - Aditya-PS-05:test-issue-143821-nested-closure-ice, r=JonathanBrouwer
add test for issue 143821 closes #143821
2 parents 8d6e68b + 2b4b02e commit 60e46fb

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
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)