Skip to content

Commit

Permalink
Removed ignore-test-compare-mode-nll from unboxed-closures tests
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
pnkfelix committed Aug 15, 2018
1 parent f8084c6 commit cd89fdb
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0597]: `x` does not live long enough
--> $DIR/unboxed-closure-region.rs:18:12
|
LL | || x //~ ERROR `x` does not live long enough
| -- ^ borrowed value does not live long enough
| |
| value captured here
LL | };
| - `x` dropped here while still borrowed
LL | _f;
| -- borrow later used here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0597`.
5 changes: 3 additions & 2 deletions src/test/ui/unboxed-closures/unboxed-closure-region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-compare-mode-nll

// Test that an unboxed closure that captures a free variable by
// reference cannot escape the region of that variable.


fn main() {
let _f = {
let x = 0;
|| x //~ ERROR `x` does not live long enough
};
_f;
}
1 change: 1 addition & 0 deletions src/test/ui/unboxed-closures/unboxed-closure-region.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ LL | || x //~ ERROR `x` does not live long enough
| capture occurs here
LL | };
| - borrowed value only lives until here
LL | _f;
LL | }
| - borrowed value needs to live until here

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0503]: cannot use `x` because it was mutably borrowed
--> $DIR/unboxed-closures-borrow-conflict.rs:19:14
|
LL | let f = || x += 1;
| -- - borrow occurs due to use of `x` in closure
| |
| borrow of `x` occurs here
LL | let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed
| ^ use of borrowed `x`
LL | f;
| - borrow later used here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0503`.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-compare-mode-nll

// Test that an unboxed closure that mutates a free variable will
// cause borrow conflicts.



fn main() {
let mut x = 0;
let f = || x += 1;
let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed
f;
}

0 comments on commit cd89fdb

Please sign in to comment.