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:
parent
f8084c675e
commit
cd89fdbbc9
@ -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`.
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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`.
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user