Skip to content

Commit f2a4d7f

Browse files
committed
bless expect-region-supply-region-2 test under polonius
Polonius also emits the error that NLL doesn't get a chance to: see comment "Borrowck doesn't get a chance to run, but if it did it should error here."
1 parent 8a21c2f commit f2a4d7f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
error: lifetime may not live long enough
2+
--> $DIR/expect-region-supply-region-2.rs:14:30
3+
|
4+
LL | fn expect_bound_supply_named<'x>() {
5+
| -- lifetime `'x` defined here
6+
...
7+
LL | closure_expecting_bound(|x: &'x u32| {
8+
| ^ - let's call the lifetime of this reference `'1`
9+
| |
10+
| requires that `'1` must outlive `'x`
11+
12+
error[E0521]: borrowed data escapes outside of closure
13+
--> $DIR/expect-region-supply-region-2.rs:20:9
14+
|
15+
LL | let mut f: Option<&u32> = None;
16+
| ----- `f` declared here, outside of the closure body
17+
...
18+
LL | closure_expecting_bound(|x: &'x u32| {
19+
| - `x` is a reference that is only valid in the closure body
20+
...
21+
LL | f = Some(x);
22+
| ^^^^^^^^^^^ `x` escapes the closure body here
23+
24+
error: lifetime may not live long enough
25+
--> $DIR/expect-region-supply-region-2.rs:14:30
26+
|
27+
LL | fn expect_bound_supply_named<'x>() {
28+
| -- lifetime `'x` defined here
29+
...
30+
LL | closure_expecting_bound(|x: &'x u32| {
31+
| ^ requires that `'x` must outlive `'static`
32+
|
33+
= help: consider replacing `'x` with `'static`
34+
35+
error: aborting due to 3 previous errors
36+
37+
For more information about this error, try `rustc --explain E0521`.

0 commit comments

Comments
 (0)