From cd89fdbbc95621e27d77e0d53899b29a3f3a738d Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 15 Aug 2018 23:39:30 +0200 Subject: [PATCH] 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). --- .../unboxed-closure-region.nll.stderr | 15 +++++++++++++++ .../ui/unboxed-closures/unboxed-closure-region.rs | 5 +++-- .../unboxed-closure-region.stderr | 1 + .../unboxed-closures-borrow-conflict.nll.stderr | 15 +++++++++++++++ .../unboxed-closures-borrow-conflict.rs | 5 +++-- 5 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr create mode 100644 src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.nll.stderr diff --git a/src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr new file mode 100644 index 00000000000..6ad57a15465 --- /dev/null +++ b/src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr @@ -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`. diff --git a/src/test/ui/unboxed-closures/unboxed-closure-region.rs b/src/test/ui/unboxed-closures/unboxed-closure-region.rs index cc635296210..da6dbc6e74f 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-region.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-region.rs @@ -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; } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-region.stderr b/src/test/ui/unboxed-closures/unboxed-closure-region.stderr index a838c3608b9..f85f3afff70 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-region.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-region.stderr @@ -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 diff --git a/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.nll.stderr new file mode 100644 index 00000000000..cadda398c6f --- /dev/null +++ b/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.nll.stderr @@ -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`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.rs b/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.rs index 734f89e5e0b..aa50fb83773 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.rs @@ -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; }