Skip to content

Commit 2dff90d

Browse files
committed
add test for issue 117146
1 parent de7a830 commit 2dff90d

3 files changed

+100
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
error[E0597]: `a` does not live long enough
2+
--> $DIR/location-insensitive-scopes-issue-117146.rs:10:18
3+
|
4+
LL | let b = |_| &a;
5+
| --- -^
6+
| | ||
7+
| | |borrowed value does not live long enough
8+
| | returning this value requires that `a` is borrowed for `'static`
9+
| value captured here
10+
...
11+
LL | }
12+
| - `a` dropped here while still borrowed
13+
|
14+
note: due to current limitations in the borrow checker, this implies a `'static` lifetime
15+
--> $DIR/location-insensitive-scopes-issue-117146.rs:20:22
16+
|
17+
LL | fn bad<F: Fn(&()) -> &()>(_: F) {}
18+
| ^^^
19+
20+
error: implementation of `Fn` is not general enough
21+
--> $DIR/location-insensitive-scopes-issue-117146.rs:13:5
22+
|
23+
LL | bad(&b);
24+
| ^^^^^^^ implementation of `Fn` is not general enough
25+
|
26+
= note: closure with signature `fn(&'2 ()) -> &()` must implement `Fn<(&'1 (),)>`, for any lifetime `'1`...
27+
= note: ...but it actually implements `Fn<(&'2 (),)>`, for some specific lifetime `'2`
28+
29+
error: implementation of `FnOnce` is not general enough
30+
--> $DIR/location-insensitive-scopes-issue-117146.rs:13:5
31+
|
32+
LL | bad(&b);
33+
| ^^^^^^^ implementation of `FnOnce` is not general enough
34+
|
35+
= note: closure with signature `fn(&'2 ()) -> &()` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`...
36+
= note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2`
37+
38+
error: aborting due to 3 previous errors
39+
40+
For more information about this error, try `rustc --explain E0597`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
error[E0597]: `a` does not live long enough
2+
--> $DIR/location-insensitive-scopes-issue-117146.rs:10:18
3+
|
4+
LL | let b = |_| &a;
5+
| --- -^
6+
| | ||
7+
| | |borrowed value does not live long enough
8+
| | returning this value requires that `a` is borrowed for `'static`
9+
| value captured here
10+
...
11+
LL | }
12+
| - `a` dropped here while still borrowed
13+
|
14+
note: due to current limitations in the borrow checker, this implies a `'static` lifetime
15+
--> $DIR/location-insensitive-scopes-issue-117146.rs:20:22
16+
|
17+
LL | fn bad<F: Fn(&()) -> &()>(_: F) {}
18+
| ^^^
19+
20+
error: implementation of `Fn` is not general enough
21+
--> $DIR/location-insensitive-scopes-issue-117146.rs:13:5
22+
|
23+
LL | bad(&b);
24+
| ^^^^^^^ implementation of `Fn` is not general enough
25+
|
26+
= note: closure with signature `fn(&'2 ()) -> &()` must implement `Fn<(&'1 (),)>`, for any lifetime `'1`...
27+
= note: ...but it actually implements `Fn<(&'2 (),)>`, for some specific lifetime `'2`
28+
29+
error: implementation of `FnOnce` is not general enough
30+
--> $DIR/location-insensitive-scopes-issue-117146.rs:13:5
31+
|
32+
LL | bad(&b);
33+
| ^^^^^^^ implementation of `FnOnce` is not general enough
34+
|
35+
= note: closure with signature `fn(&'2 ()) -> &()` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`...
36+
= note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2`
37+
38+
error: aborting due to 3 previous errors
39+
40+
For more information about this error, try `rustc --explain E0597`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This is a non-regression test for issue #117146, where NLL and `-Zpolonius=next` computed
2+
// different loan scopes when a region flowed into an SCC whose representative was an existential
3+
// region.
4+
5+
// revisions: nll polonius
6+
// [polonius] compile-flags: -Zpolonius=next
7+
8+
fn main() {
9+
let a = ();
10+
let b = |_| &a;
11+
//[nll]~^ ERROR `a` does not live long enough
12+
//[polonius]~^^ ERROR `a` does not live long enough
13+
bad(&b);
14+
//[nll]~^ ERROR implementation of `Fn`
15+
//[nll]~| ERROR implementation of `FnOnce`
16+
//[polonius]~^^^ ERROR implementation of `Fn`
17+
//[polonius]~| ERROR implementation of `FnOnce`
18+
}
19+
20+
fn bad<F: Fn(&()) -> &()>(_: F) {}

0 commit comments

Comments
 (0)