Skip to content

Commit cd89fdb

Browse files
committedAug 15, 2018
Removed ignore-test-compare-mode-nll from unboxed-closures tests
by strengthening the tests (by adding no-op references to the closures doing the borrows after the conflicting borrows, thus forcing the lifetimes to resemble lexical scopes even under NLL).
1 parent f8084c6 commit cd89fdb

5 files changed

+37
-4
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0597]: `x` does not live long enough
2+
--> $DIR/unboxed-closure-region.rs:18:12
3+
|
4+
LL | || x //~ ERROR `x` does not live long enough
5+
| -- ^ borrowed value does not live long enough
6+
| |
7+
| value captured here
8+
LL | };
9+
| - `x` dropped here while still borrowed
10+
LL | _f;
11+
| -- borrow later used here
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0597`.

‎src/test/ui/unboxed-closures/unboxed-closure-region.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-compare-mode-nll
12-
1311
// Test that an unboxed closure that captures a free variable by
1412
// reference cannot escape the region of that variable.
13+
14+
1515
fn main() {
1616
let _f = {
1717
let x = 0;
1818
|| x //~ ERROR `x` does not live long enough
1919
};
20+
_f;
2021
}

‎src/test/ui/unboxed-closures/unboxed-closure-region.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LL | || x //~ ERROR `x` does not live long enough
77
| capture occurs here
88
LL | };
99
| - borrowed value only lives until here
10+
LL | _f;
1011
LL | }
1112
| - borrowed value needs to live until here
1213

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0503]: cannot use `x` because it was mutably borrowed
2+
--> $DIR/unboxed-closures-borrow-conflict.rs:19:14
3+
|
4+
LL | let f = || x += 1;
5+
| -- - borrow occurs due to use of `x` in closure
6+
| |
7+
| borrow of `x` occurs here
8+
LL | let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed
9+
| ^ use of borrowed `x`
10+
LL | f;
11+
| - borrow later used here
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0503`.

‎src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-compare-mode-nll
12-
1311
// Test that an unboxed closure that mutates a free variable will
1412
// cause borrow conflicts.
1513

14+
15+
1616
fn main() {
1717
let mut x = 0;
1818
let f = || x += 1;
1919
let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed
20+
f;
2021
}

0 commit comments

Comments
 (0)
Please sign in to comment.