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 0000000000000..6ad57a15465d3 --- /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 cc635296210a0..da6dbc6e74f86 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 a838c3608b9a9..f85f3afff70e8 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 0000000000000..cadda398c6f33 --- /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 734f89e5e0b8b..aa50fb837733c 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; }