Skip to content

Commit 419ed8b

Browse files
committed
add test for rust-lang#53432.
1 parent b9eaad2 commit 419ed8b

2 files changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
let f = move || {};
3+
let _action = move || {
4+
|| f() // The `nested` closure
5+
//~^ ERROR lifetime may not live long enough
6+
};
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: lifetime may not live long enough
2+
--> $DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:4:9
3+
|
4+
LL | let _action = move || {
5+
| -------
6+
| | |
7+
| | return type of closure is [closure@$DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:4:9: 4:15 f:&'2 [closure@$DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:2:13: 2:23]]
8+
| lifetime `'1` represents this closure's body
9+
LL | || f() // The `nested` closure
10+
| ^^^^^^ returning this value requires that `'1` must outlive `'2`
11+
|
12+
= note: closure implements `Fn`, so references to captured variables can't escape the closure
13+
14+
error: aborting due to previous error
15+

0 commit comments

Comments
 (0)