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).
This commit is contained in:
Felix S. Klock II 2018-08-15 23:39:30 +02:00
parent f8084c675e
commit cd89fdbbc9
5 changed files with 37 additions and 4 deletions

View File

@ -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`.

View File

@ -8,13 +8,14 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// ignore-compare-mode-nll
// Test that an unboxed closure that captures a free variable by // Test that an unboxed closure that captures a free variable by
// reference cannot escape the region of that variable. // reference cannot escape the region of that variable.
fn main() { fn main() {
let _f = { let _f = {
let x = 0; let x = 0;
|| x //~ ERROR `x` does not live long enough || x //~ ERROR `x` does not live long enough
}; };
_f;
} }

View File

@ -7,6 +7,7 @@ LL | || x //~ ERROR `x` does not live long enough
| capture occurs here | capture occurs here
LL | }; LL | };
| - borrowed value only lives until here | - borrowed value only lives until here
LL | _f;
LL | } LL | }
| - borrowed value needs to live until here | - borrowed value needs to live until here

View File

@ -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`.

View File

@ -8,13 +8,14 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// ignore-compare-mode-nll
// Test that an unboxed closure that mutates a free variable will // Test that an unboxed closure that mutates a free variable will
// cause borrow conflicts. // cause borrow conflicts.
fn main() { fn main() {
let mut x = 0; let mut x = 0;
let f = || x += 1; let f = || x += 1;
let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed
f;
} }