Skip to content

Commit 97bbcab

Browse files
committed
Added multiple parameter closure test.
New test has multiple parameters in a closure with longer names in order to clarify the issues relating to odd spans.
1 parent 876774b commit 97bbcab

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/test/ui/nll/issue-52534.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@
1414
fn foo(_: impl FnOnce(&u32) -> &u32) {
1515
}
1616

17+
fn baz(_: impl FnOnce(&u32, u32) -> &u32) {
18+
}
19+
1720
fn bar() {
1821
let x = 22;
1922
foo(|a| &x)
2023
}
2124

25+
fn foobar() {
26+
let y = 22;
27+
baz(|first, second| &y)
28+
}
29+
2230
fn main() { }

src/test/ui/nll/issue-52534.stderr

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0597]: `x` does not live long enough
2-
--> $DIR/issue-52534.rs:19:14
2+
--> $DIR/issue-52534.rs:22:14
33
|
44
LL | foo(|a| &x)
55
| - ^ `x` would have to be valid for `'0`
@@ -8,6 +8,16 @@ LL | foo(|a| &x)
88
LL | }
99
| - ...but `x` is only valid for the duration of the `bar` function, so it is dropped here while still borrowed
1010

11-
error: aborting due to previous error
11+
error[E0597]: `y` does not live long enough
12+
--> $DIR/issue-52534.rs:27:26
13+
|
14+
LL | baz(|first, second| &y)
15+
| - ^ `y` would have to be valid for `'0`
16+
| |
17+
| has type `&'0 u32`
18+
LL | }
19+
| - ...but `y` is only valid for the duration of the `foobar` function, so it is dropped here while still borrowed
20+
21+
error: aborting due to 2 previous errors
1222

1323
For more information about this error, try `rustc --explain E0597`.

0 commit comments

Comments
 (0)