about summary refs log tree commit diff
path: root/src/test/ui/borrowck
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-10-17 23:16:10 +0000
committerbors <bors@rust-lang.org>2018-10-17 23:16:10 +0000
commitf7eb7fbbf6bca0eaa146c4a48cd39c133a257706 (patch)
treedff6498867ed6b5d5f6765fec64efe4bdc6ef8e0 /src/test/ui/borrowck
parent1dceaddfbe163e2d916c904b98923342730ba970 (diff)
parent539404b77d1e443793c653ae03b207c62b3b1ae0 (diff)
Auto merge of #55134 - davidtwco:issue-55118, r=pnkfelix
NLL: change compare-mode=nll to use borrowck=migrate

Fixes #55118.

This PR is split into two parts:

The first commit is a minor change that fixes a flaw in the existing `borrowck=migrate` implementation whereby a lint that was promoted to an error in the AST borrow checker would result in the same lint from the NLL borrow checker being downgraded to a warning in migrate mode. This PR fixes this by ensuring lints are exempt from buffering in the NLL borrow checker.

The second commit updates `compiletest` to make the NLL compare mode use `-Z borrowck=migrate` rather than `-Z borrowck=mir`. The third commit shows all the test output changes that result from this.

r? @pnkfelix
Diffstat (limited to 'src/test/ui/borrowck')
-rw-r--r--src/test/ui/borrowck/borrowck-closures-unique.nll.stderr8
-rw-r--r--src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr19
-rw-r--r--src/test/ui/borrowck/borrowck-fn-in-const-a.ast.nll.stderr20
-rw-r--r--src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr32
-rw-r--r--src/test/ui/borrowck/borrowck-in-static.nll.stderr17
-rw-r--r--src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr13
-rw-r--r--src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr50
-rw-r--r--src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr13
-rw-r--r--src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr29
-rw-r--r--src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr11
-rw-r--r--src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr11
-rw-r--r--src/test/ui/borrowck/borrowck-move-out-of-static-item.ast.nll.stderr18
-rw-r--r--src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr29
-rw-r--r--src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr11
-rw-r--r--src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr12
-rw-r--r--src/test/ui/borrowck/issue-51415.nll.stderr11
-rw-r--r--src/test/ui/borrowck/issue-7573.nll.stderr14
-rw-r--r--src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.nll.stderr33
-rw-r--r--src/test/ui/borrowck/mutability-errors.nll.stderr26
-rw-r--r--src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr12
-rw-r--r--src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr12
-rw-r--r--src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr12
-rw-r--r--src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr21
23 files changed, 348 insertions, 86 deletions
diff --git a/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr b/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr
index 231ae53fe82..771ef88a662 100644
--- a/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr
@@ -40,15 +40,19 @@ LL |     let c2 = || set(x); //~ ERROR two closures require unique access to `x`
 LL |     c1;
    |     -- first borrow later used here
 
-error[E0594]: cannot assign to `x`, as it is not declared as mutable
+warning[E0594]: cannot assign to `x`, as it is not declared as mutable
   --> $DIR/borrowck-closures-unique.rs:57:38
    |
 LL | fn e(x: &'static mut isize) {
    |      - help: consider changing this to be mutable: `mut x`
 LL |     let c1 = |y: &'static mut isize| x = y; //~ ERROR closure cannot assign to immutable argument
    |                                      ^^^^^ cannot assign
+   |
+   = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
+           It represents potential unsoundness in your code.
+           This warning will become a hard error in the future.
 
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
 
 Some errors occurred: E0500, E0524, E0594.
 For more information about an error, try `rustc --explain E0500`.
diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr b/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr
index 5721c52ba21..88ae73b6368 100644
--- a/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr
@@ -20,7 +20,7 @@ LL |                    //[mir]~^ ERROR cannot borrow `x` as mutable more than o
 LL |                    *y = 1;
    |                    ------ first borrow later used here
 
-error: captured variable cannot escape `FnMut` closure body
+warning: captured variable cannot escape `FnMut` closure body
   --> $DIR/borrowck-describe-lvalue.rs:305:16
    |
 LL |              || {
@@ -36,6 +36,9 @@ LL | |                 }
    |
    = note: `FnMut` closures only have access to their captured variables while they are executing...
    = note: ...therefore, they cannot allow references to captured variables to escape
+   = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
+           It represents potential unsoundness in your code.
+           This warning will become a hard error in the future.
 
 error[E0503]: cannot use `f.x` because it was mutably borrowed
   --> $DIR/borrowck-describe-lvalue.rs:53:9
@@ -339,7 +342,7 @@ LL |             &[_, F {x: ref xf, ..}] => println!("{}", xf),
 LL |         drop(x);
    |              - mutable borrow later used here
 
-error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
+warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
   --> $DIR/borrowck-describe-lvalue.rs:245:29
    |
 LL |             let x = &mut block;
@@ -349,8 +352,12 @@ LL |             let p: &'a u8 = &*block.current;
 ...
 LL |             drop(x);
    |                  - mutable borrow later used here
+   |
+   = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
+           It represents potential unsoundness in your code.
+           This warning will become a hard error in the future.
 
-error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
+warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
   --> $DIR/borrowck-describe-lvalue.rs:260:33
    |
 LL |             let x = &mut block;
@@ -360,6 +367,10 @@ LL |             let p : *const u8 = &*(*block).current;
 ...
 LL |             drop(x);
    |                  - mutable borrow later used here
+   |
+   = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
+           It represents potential unsoundness in your code.
+           This warning will become a hard error in the future.
 
 error[E0382]: use of moved value: `x`
   --> $DIR/borrowck-describe-lvalue.rs:318:22
@@ -371,7 +382,7 @@ LL |                 drop(x); //[ast]~ ERROR use of moved value: `x`
    |
    = note: move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait
 
-error: aborting due to 32 previous errors
+error: aborting due to 29 previous errors
 
 Some errors occurred: E0382, E0499, E0502, E0503.
 For more information about an error, try `rustc --explain E0382`.
diff --git a/src/test/ui/borrowck/borrowck-fn-in-const-a.ast.nll.stderr b/src/test/ui/borrowck/borrowck-fn-in-const-a.ast.nll.stderr
new file mode 100644
index 00000000000..b171a48ac50
--- /dev/null
+++ b/src/test/ui/borrowck/borrowck-fn-in-const-a.ast.nll.stderr
@@ -0,0 +1,20 @@
+error[E0507]: cannot move out of borrowed content
+  --> $DIR/borrowck-fn-in-const-a.rs:19:16
+   |
+LL |         return *x //[ast]~ ERROR cannot move out of borrowed content [E0507]
+   |                ^^ cannot move out of borrowed content
+
+error[E0507]: cannot move out of `*x` which is behind a `&` reference
+  --> $DIR/borrowck-fn-in-const-a.rs:19:16
+   |
+LL |     fn broken(x: &String) -> String {
+   |                  ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
+LL |         return *x //[ast]~ ERROR cannot move out of borrowed content [E0507]
+   |                ^^
+   |                |
+   |                cannot move out of `*x` which is behind a `&` reference
+   |                `x` is a `&` reference, so the data it refers to cannot be moved
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr b/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr
index 25eb69ad937..0ab3d3ea5cd 100644
--- a/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr
@@ -1,3 +1,13 @@
+error[E0507]: cannot move out of `*__next` which is behind a `&` reference
+  --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:10
+   |
+LL |     for &a in x.iter() {    //~ ERROR cannot move out
+   |         -^
+   |         ||
+   |         |cannot move out of `*__next` which is behind a `&` reference
+   |         |`__next` is a `&` reference, so the data it refers to cannot be moved
+   |         help: consider changing this to be a mutable reference: `&mut a`
+
 error[E0507]: cannot move out of borrowed content
   --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:15
    |
@@ -13,6 +23,16 @@ note: move occurs because `a` has type `&mut i32`, which does not implement the
 LL |     for &a in x.iter() {    //~ ERROR cannot move out
    |          ^
 
+error[E0507]: cannot move out of `*__next` which is behind a `&` reference
+  --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:28:10
+   |
+LL |     for &a in &f.a {  //~ ERROR cannot move out
+   |         -^
+   |         ||
+   |         |cannot move out of `*__next` which is behind a `&` reference
+   |         |`__next` is a `&` reference, so the data it refers to cannot be moved
+   |         help: consider changing this to be a mutable reference: `&mut a`
+
 error[E0507]: cannot move out of borrowed content
   --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:28:15
    |
@@ -28,6 +48,16 @@ note: move occurs because `a` has type `std::boxed::Box<isize>`, which does not
 LL |     for &a in &f.a {  //~ ERROR cannot move out
    |          ^
 
+error[E0507]: cannot move out of `*__next` which is behind a `&` reference
+  --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:32:10
+   |
+LL |     for &a in x.iter() {    //~ ERROR cannot move out
+   |         -^
+   |         ||
+   |         |cannot move out of `*__next` which is behind a `&` reference
+   |         |`__next` is a `&` reference, so the data it refers to cannot be moved
+   |         help: consider changing this to be a mutable reference: `&mut a`
+
 error[E0507]: cannot move out of borrowed content
   --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:32:15
    |
@@ -43,6 +73,6 @@ note: move occurs because `a` has type `std::boxed::Box<i32>`, which does not im
 LL |     for &a in x.iter() {    //~ ERROR cannot move out
    |          ^
 
-error: aborting due to 3 previous errors
+error: aborting due to 6 previous errors
 
 For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/borrowck-in-static.nll.stderr b/src/test/ui/borrowck/borrowck-in-static.nll.stderr
index 45fa1764f70..ba42dc24363 100644
--- a/src/test/ui/borrowck/borrowck-in-static.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-in-static.nll.stderr
@@ -6,6 +6,21 @@ LL |     let x = Box::new(0);
 LL |     Box::new(|| x) //~ ERROR cannot move out of captured outer variable
    |                 ^ cannot move out of captured variable in an `Fn` closure
 
-error: aborting due to previous error
+error[E0507]: cannot move out of `x`, as it is a captured variable in a `Fn` closure
+  --> $DIR/borrowck-in-static.rs:15:17
+   |
+LL |     Box::new(|| x) //~ ERROR cannot move out of captured outer variable
+   |                 ^
+   |                 |
+   |                 cannot move out of `x`, as it is a captured variable in a `Fn` closure
+   |                 cannot move
+   |
+help: consider changing this to accept closures that implement `FnMut`
+  --> $DIR/borrowck-in-static.rs:15:14
+   |
+LL |     Box::new(|| x) //~ ERROR cannot move out of captured outer variable
+   |              ^^^^
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr b/src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr
index cdbfab8bd05..0445a75d61a 100644
--- a/src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr
@@ -7,6 +7,17 @@ LL |         let _b = *y; //~ ERROR cannot move out
    |                  cannot move out of borrowed content
    |                  help: consider removing the `*`: `y`
 
-error: aborting due to previous error
+error[E0507]: cannot move out of `*y` which is behind a `&` reference
+  --> $DIR/borrowck-issue-2657-2.rs:17:18
+   |
+LL |       Some(ref y) => {
+   |            ----- help: consider changing this to be a mutable reference: `ref mut y`
+LL |         let _b = *y; //~ ERROR cannot move out
+   |                  ^^
+   |                  |
+   |                  cannot move out of `*y` which is behind a `&` reference
+   |                  `y` is a `&` reference, so the data it refers to cannot be moved
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr b/src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr
index 2df520a936c..99f69515a47 100644
--- a/src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr
@@ -24,6 +24,42 @@ LL |                   num2) => (),
 LL |         Foo::Foo2(num) => (),
    |                   ^^^
 
+error[E0507]: cannot move out of `f.0` which is behind a `&` reference
+  --> $DIR/borrowck-move-error-with-note.rs:23:19
+   |
+LL |     let f = &Foo::Foo1(box 1, box 2);
+   |             ------------------------ help: consider changing this to be a mutable reference: `&mut Foo::Foo1(box 1, box 2)`
+...
+LL |         Foo::Foo1(num1,
+   |                   ^^^^
+   |                   |
+   |                   cannot move out of `f.0` which is behind a `&` reference
+   |                   `f` is a `&` reference, so the data it refers to cannot be moved
+
+error[E0507]: cannot move out of `f.1` which is behind a `&` reference
+  --> $DIR/borrowck-move-error-with-note.rs:24:19
+   |
+LL |     let f = &Foo::Foo1(box 1, box 2);
+   |             ------------------------ help: consider changing this to be a mutable reference: `&mut Foo::Foo1(box 1, box 2)`
+...
+LL |                   num2) => (),
+   |                   ^^^^
+   |                   |
+   |                   cannot move out of `f.1` which is behind a `&` reference
+   |                   `f` is a `&` reference, so the data it refers to cannot be moved
+
+error[E0507]: cannot move out of `f.0` which is behind a `&` reference
+  --> $DIR/borrowck-move-error-with-note.rs:25:19
+   |
+LL |     let f = &Foo::Foo1(box 1, box 2);
+   |             ------------------------ help: consider changing this to be a mutable reference: `&mut Foo::Foo1(box 1, box 2)`
+...
+LL |         Foo::Foo2(num) => (),
+   |                   ^^^
+   |                   |
+   |                   cannot move out of `f.0` which is behind a `&` reference
+   |                   `f` is a `&` reference, so the data it refers to cannot be moved
+
 error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
   --> $DIR/borrowck-move-error-with-note.rs:39:11
    |
@@ -61,7 +97,19 @@ note: move occurs because `n` has type `std::boxed::Box<isize>`, which does not
 LL |         n => {
    |         ^
 
-error: aborting due to 3 previous errors
+error[E0507]: cannot move out of `a.a` which is behind a `&` reference
+  --> $DIR/borrowck-move-error-with-note.rs:59:9
+   |
+LL |     let a = &A { a: box 1 };
+   |             --------------- help: consider changing this to be a mutable reference: `&mut A { a: box 1 }`
+...
+LL |         n => {
+   |         ^
+   |         |
+   |         cannot move out of `a.a` which is behind a `&` reference
+   |         `a` is a `&` reference, so the data it refers to cannot be moved
+
+error: aborting due to 7 previous errors
 
 Some errors occurred: E0507, E0509.
 For more information about an error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr b/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr
index c3a2180b9f0..83c5b82957d 100644
--- a/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr
@@ -7,6 +7,17 @@ LL |     let y = *x; //~ ERROR cannot move out of dereference of raw pointer
    |             cannot move out of dereference of raw pointer
    |             help: consider removing the `*`: `x`
 
-error: aborting due to previous error
+error[E0507]: cannot move out of `*x` which is behind a `*const` pointer
+  --> $DIR/borrowck-move-from-unsafe-ptr.rs:13:13
+   |
+LL | unsafe fn foo(x: *const Box<isize>) -> Box<isize> {
+   |                  ----------------- help: consider changing this to be a mutable pointer: `*mut std::boxed::Box<isize>`
+LL |     let y = *x; //~ ERROR cannot move out of dereference of raw pointer
+   |             ^^
+   |             |
+   |             cannot move out of `*x` which is behind a `*const` pointer
+   |             `x` is a `*const` pointer, so the data it refers to cannot be moved
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr b/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr
index 49c2ec0dcf4..f22aca99949 100644
--- a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr
@@ -14,6 +14,15 @@ note: move occurs because `_x` has type `std::string::String`, which does not im
 LL | fn arg_item(&_x: &String) {}
    |              ^^
 
+error[E0507]: cannot move out of data in a `&` reference
+  --> $DIR/borrowck-move-in-irrefut-pat.rs:16:14
+   |
+LL | fn arg_item(&_x: &String) {}
+   |              ^^
+   |              |
+   |              cannot move out of data in a `&` reference
+   |              cannot move
+
 error[E0507]: cannot move out of borrowed content
   --> $DIR/borrowck-move-in-irrefut-pat.rs:21:11
    |
@@ -30,6 +39,24 @@ note: move occurs because `_x` has type `std::string::String`, which does not im
 LL |     with(|&_x| ())
    |            ^^
 
+error[E0507]: cannot move out of data in a `&` reference
+  --> $DIR/borrowck-move-in-irrefut-pat.rs:21:12
+   |
+LL |     with(|&_x| ())
+   |            ^^
+   |            |
+   |            cannot move out of data in a `&` reference
+   |            cannot move
+
+error[E0507]: cannot move out of data in a `&` reference
+  --> $DIR/borrowck-move-in-irrefut-pat.rs:27:10
+   |
+LL |     let &_x = &"hi".to_string();
+   |          ^^
+   |          |
+   |          cannot move out of data in a `&` reference
+   |          cannot move
+
 error[E0507]: cannot move out of borrowed content
   --> $DIR/borrowck-move-in-irrefut-pat.rs:27:15
    |
@@ -45,6 +72,6 @@ note: move occurs because `_x` has type `std::string::String`, which does not im
 LL |     let &_x = &"hi".to_string();
    |          ^^
 
-error: aborting due to 3 previous errors
+error: aborting due to 6 previous errors
 
 For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr
index d58beabb303..ba74cd2514e 100644
--- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr
@@ -4,6 +4,15 @@ error[E0507]: cannot move out of an `Rc`
 LL |     let _x = Rc::new(vec![1, 2]).into_iter();
    |              ^^^^^^^^^^^^^^^^^^^ cannot move out of an `Rc`
 
-error: aborting due to previous error
+error[E0507]: cannot move out of data in a `&` reference
+  --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:17:14
+   |
+LL |     let _x = Rc::new(vec![1, 2]).into_iter();
+   |              ^^^^^^^^^^^^^^^^^^^
+   |              |
+   |              cannot move out of data in a `&` reference
+   |              cannot move
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr
index c9c8cf104ce..205044bb368 100644
--- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr
@@ -7,6 +7,15 @@ LL |     let _x = *Rc::new("hi".to_string());
    |              cannot move out of an `Rc`
    |              help: consider removing the `*`: `Rc::new("hi".to_string())`
 
-error: aborting due to previous error
+error[E0507]: cannot move out of data in a `&` reference
+  --> $DIR/borrowck-move-out-of-overloaded-deref.rs:14:14
+   |
+LL |     let _x = *Rc::new("hi".to_string());
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              |
+   |              cannot move out of data in a `&` reference
+   |              cannot move
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/borrowck-move-out-of-static-item.ast.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-static-item.ast.nll.stderr
new file mode 100644
index 00000000000..675458d8c2b
--- /dev/null
+++ b/src/test/ui/borrowck/borrowck-move-out-of-static-item.ast.nll.stderr
@@ -0,0 +1,18 @@
+error[E0507]: cannot move out of static item
+  --> $DIR/borrowck-move-out-of-static-item.rs:28:10
+   |
+LL |     test(BAR); //[ast]~ ERROR cannot move out of static item [E0507]
+   |          ^^^ cannot move out of static item
+
+error[E0507]: cannot move out of immutable static item `BAR`
+  --> $DIR/borrowck-move-out-of-static-item.rs:28:10
+   |
+LL |     test(BAR); //[ast]~ ERROR cannot move out of static item [E0507]
+   |          ^^^
+   |          |
+   |          cannot move out of immutable static item `BAR`
+   |          cannot move
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr
index f3430ba4e06..dea42c53992 100644
--- a/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr
@@ -26,6 +26,31 @@ LL |                 //~| to prevent move
 LL |                   Foo { string: b }] => {
    |
 
-error: aborting due to previous error
+error[E0507]: cannot move out of `tail[..].string` which is behind a `&` reference
+  --> $DIR/borrowck-move-out-of-vec-tail.rs:30:33
+   |
+LL |         [_, ref tail..] => {
+   |             -------- help: consider changing this to be a mutable reference: `ref mut tail`
+LL |             match tail {
+LL |                 &[Foo { string: a },
+   |                                 ^
+   |                                 |
+   |                                 cannot move out of `tail[..].string` which is behind a `&` reference
+   |                                 `tail` is a `&` reference, so the data it refers to cannot be moved
+
+error[E0507]: cannot move out of `tail[..].string` which is behind a `&` reference
+  --> $DIR/borrowck-move-out-of-vec-tail.rs:34:33
+   |
+LL |         [_, ref tail..] => {
+   |             -------- help: consider changing this to be a mutable reference: `ref mut tail`
+...
+LL |                   Foo { string: b }] => {
+   |                                 ^
+   |                                 |
+   |                                 cannot move out of `tail[..].string` which is behind a `&` reference
+   |                                 `tail` is a `&` reference, so the data it refers to cannot be moved
+
+error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0508`.
+Some errors occurred: E0507, E0508.
+For more information about an error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr
index 92e10c258c2..05fd6d71520 100644
--- a/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr
+++ b/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr
@@ -7,6 +7,15 @@ LL |     let bad = v[0];
    |               cannot move out of borrowed content
    |               help: consider borrowing here: `&v[0]`
 
-error: aborting due to previous error
+error[E0507]: cannot move out of data in a `&` reference
+  --> $DIR/borrowck-overloaded-index-move-from-vec.rs:30:15
+   |
+LL |     let bad = v[0];
+   |               ^^^^
+   |               |
+   |               cannot move out of data in a `&` reference
+   |               cannot move
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr b/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr
deleted file mode 100644
index e3211f83850..00000000000
--- a/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error: unsatisfied lifetime constraints
-  --> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:19:5
-   |
-LL | fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> {
-   |                      -- -- lifetime `'b` defined here
-   |                      |
-   |                      lifetime `'a` defined here
-LL |     S { pointer: &mut *p.pointer }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/borrowck/issue-51415.nll.stderr b/src/test/ui/borrowck/issue-51415.nll.stderr
index d4340938eeb..ee7e3e71962 100644
--- a/src/test/ui/borrowck/issue-51415.nll.stderr
+++ b/src/test/ui/borrowck/issue-51415.nll.stderr
@@ -13,6 +13,15 @@ note: move occurs because `s` has type `std::string::String`, which does not imp
 LL |     let opt = a.iter().enumerate().find(|(_, &s)| {
    |                                               ^
 
-error: aborting due to previous error
+error[E0507]: cannot move out of data in a `&` reference
+  --> $DIR/issue-51415.rs:16:47
+   |
+LL |     let opt = a.iter().enumerate().find(|(_, &s)| {
+   |                                               ^
+   |                                               |
+   |                                               cannot move out of data in a `&` reference
+   |                                               cannot move
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/issue-7573.nll.stderr b/src/test/ui/borrowck/issue-7573.nll.stderr
deleted file mode 100644
index 372df61d78c..00000000000
--- a/src/test/ui/borrowck/issue-7573.nll.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error: borrowed data escapes outside of closure
-  --> $DIR/issue-7573.rs:32:9
-   |
-LL |     let mut lines_to_use: Vec<&CrateId> = Vec::new();
-   |         ---------------- `lines_to_use` is declared here, outside of the closure body
-LL |         //~^ NOTE cannot infer an appropriate lifetime
-LL |     let push_id = |installed_id: &CrateId| {
-   |                    ------------ `installed_id` is a reference that is only valid in the closure body
-...
-LL |         lines_to_use.push(installed_id);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `installed_id` escapes the closure body here
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.nll.stderr b/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.nll.stderr
new file mode 100644
index 00000000000..d25fc759775
--- /dev/null
+++ b/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.nll.stderr
@@ -0,0 +1,33 @@
+error[E0507]: cannot move out of borrowed content
+  --> $DIR/move-in-static-initializer-issue-38520.rs:25:23
+   |
+LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507
+   |                       ^^^ cannot move out of borrowed content
+
+error[E0507]: cannot move out of data in a `&` reference
+  --> $DIR/move-in-static-initializer-issue-38520.rs:25:23
+   |
+LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507
+   |                       ^^^
+   |                       |
+   |                       cannot move out of data in a `&` reference
+   |                       cannot move
+
+error[E0507]: cannot move out of borrowed content
+  --> $DIR/move-in-static-initializer-issue-38520.rs:27:22
+   |
+LL | const Z: usize = get(*&X); //[ast]~ ERROR E0507
+   |                      ^^^ cannot move out of borrowed content
+
+error[E0507]: cannot move out of data in a `&` reference
+  --> $DIR/move-in-static-initializer-issue-38520.rs:27:22
+   |
+LL | const Z: usize = get(*&X); //[ast]~ ERROR E0507
+   |                      ^^^
+   |                      |
+   |                      cannot move out of data in a `&` reference
+   |                      cannot move
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/mutability-errors.nll.stderr b/src/test/ui/borrowck/mutability-errors.nll.stderr
index 14c41bb81b2..bb45fe2da81 100644
--- a/src/test/ui/borrowck/mutability-errors.nll.stderr
+++ b/src/test/ui/borrowck/mutability-errors.nll.stderr
@@ -277,7 +277,7 @@ LL |     &mut x; //~ ERROR
 LL |     &mut x.0; //~ ERROR
    |     ^^^^^^^^ cannot borrow as mutable
 
-error[E0594]: cannot assign to `x`, as it is not declared as mutable
+warning[E0594]: cannot assign to `x`, as it is not declared as mutable
   --> $DIR/mutability-errors.rs:70:9
    |
 LL | fn imm_capture(x: (i32,)) {
@@ -285,8 +285,12 @@ LL | fn imm_capture(x: (i32,)) {
 LL |     || { //~ ERROR
 LL |         x = (1,);
    |         ^^^^^^^^ cannot assign
+   |
+   = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
+           It represents potential unsoundness in your code.
+           This warning will become a hard error in the future.
 
-error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable
+warning[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable
   --> $DIR/mutability-errors.rs:71:9
    |
 LL | fn imm_capture(x: (i32,)) {
@@ -294,8 +298,12 @@ LL | fn imm_capture(x: (i32,)) {
 ...
 LL |         x.0 = 1;
    |         ^^^^^^^ cannot assign
+   |
+   = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
+           It represents potential unsoundness in your code.
+           This warning will become a hard error in the future.
 
-error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
+warning[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
   --> $DIR/mutability-errors.rs:72:9
    |
 LL | fn imm_capture(x: (i32,)) {
@@ -303,8 +311,12 @@ LL | fn imm_capture(x: (i32,)) {
 ...
 LL |         &mut x;
    |         ^^^^^^ cannot borrow as mutable
+   |
+   = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
+           It represents potential unsoundness in your code.
+           This warning will become a hard error in the future.
 
-error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
+warning[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable
   --> $DIR/mutability-errors.rs:73:9
    |
 LL | fn imm_capture(x: (i32,)) {
@@ -312,6 +324,10 @@ LL | fn imm_capture(x: (i32,)) {
 ...
 LL |         &mut x.0;
    |         ^^^^^^^^ cannot borrow as mutable
+   |
+   = warning: This error has been downgraded to a warning for backwards compatibility with previous releases.
+           It represents potential unsoundness in your code.
+           This warning will become a hard error in the future.
 
 error[E0594]: cannot assign to `x`, as it is not declared as mutable
   --> $DIR/mutability-errors.rs:76:9
@@ -373,7 +389,7 @@ error[E0596]: cannot borrow `X.0` as mutable, as `X` is an immutable static item
 LL |     &mut X.0; //~ ERROR
    |     ^^^^^^^^ cannot borrow as mutable
 
-error: aborting due to 38 previous errors
+error: aborting due to 34 previous errors
 
 Some errors occurred: E0594, E0596.
 For more information about an error, try `rustc --explain E0594`.
diff --git a/src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr b/src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr
deleted file mode 100644
index 787fc4d8729..00000000000
--- a/src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error: borrowed data escapes outside of closure
-  --> $DIR/regions-escape-bound-fn-2.rs:18:18
-   |
-LL |     let mut x = None;
-   |         ----- `x` is declared here, outside of the closure body
-LL |     with_int(|y| x = Some(y));
-   |               -  ^^^^^^^^^^^ `y` escapes the closure body here
-   |               |
-   |               `y` is a reference that is only valid in the closure body
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr b/src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr
deleted file mode 100644
index 91f1f00ce30..00000000000
--- a/src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error: borrowed data escapes outside of closure
-  --> $DIR/regions-escape-bound-fn.rs:18:18
-   |
-LL |     let mut x: Option<&isize> = None;
-   |         ----- `x` is declared here, outside of the closure body
-LL |     with_int(|y| x = Some(y));
-   |               -  ^^^^^^^^^^^ `y` escapes the closure body here
-   |               |
-   |               `y` is a reference that is only valid in the closure body
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr b/src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr
deleted file mode 100644
index 44e7018fdd7..00000000000
--- a/src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error: borrowed data escapes outside of closure
-  --> $DIR/regions-escape-unboxed-closure.rs:16:23
-   |
-LL |     let mut x: Option<&isize> = None;
-   |         ----- `x` is declared here, outside of the closure body
-LL |     with_int(&mut |y| x = Some(y));
-   |                    -  ^^^^^^^^^^^ `y` escapes the closure body here
-   |                    |
-   |                    `y` is a reference that is only valid in the closure body
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr b/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr
index 0eb5fc8c324..0844ac32b8b 100644
--- a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr
+++ b/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr
@@ -7,6 +7,25 @@ LL |     call(|| {
 LL |         y.into_iter();
    |         ^ cannot move out of captured variable in an `Fn` closure
 
-error: aborting due to previous error
+error[E0507]: cannot move out of `y`, as it is a captured variable in a `Fn` closure
+  --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:21:9
+   |
+LL |         y.into_iter();
+   |         ^
+   |         |
+   |         cannot move out of `y`, as it is a captured variable in a `Fn` closure
+   |         cannot move
+   |
+help: consider changing this to accept closures that implement `FnMut`
+  --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:20:10
+   |
+LL |       call(|| {
+   |  __________^
+LL | |         y.into_iter();
+LL | |         //~^ ERROR cannot move out of captured outer variable in an `Fn` closure
+LL | |     });
+   | |_____^
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0507`.