Auto merge of #52359 - matthewjasper:combine-move-error-reporting, r=pnkfelix

[NLL] Small move error reporting improvements

* Use a MirBorrowckContext when reporting errors to be more uniform with other error reporting
* Add a special message for the case of trying to move from capture variables in `Fn` and `FnMut` closures.

part of #51028
This commit is contained in:
bors 2018-07-22 08:52:05 +00:00
commit aeca042f84
12 changed files with 101 additions and 88 deletions

View file

@ -1,8 +1,8 @@
error[E0507]: cannot move out of borrowed content
error[E0507]: cannot move out of captured variable in an `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 borrowed content
| ^ cannot move out of captured variable in an `Fn` closure
error: aborting due to previous error

View file

@ -1,8 +1,8 @@
error[E0507]: cannot move out of borrowed content
error[E0507]: cannot move out of captured variable in an `Fn` closure
--> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:21:9
|
LL | y.into_iter();
| ^ cannot move out of borrowed content
| ^ cannot move out of captured variable in an `Fn` closure
error: aborting due to previous error

View file

@ -1,16 +0,0 @@
error[E0507]: cannot move out of borrowed content
--> $DIR/E0161.rs:14:28
|
LL | let _x: Box<str> = box *"hello"; //~ ERROR E0161
| ^^^^^^^^ cannot move out of borrowed content
error[E0161]: cannot move a value of type str: the size of str cannot be statically determined
--> $DIR/E0161.rs:14:28
|
LL | let _x: Box<str> = box *"hello"; //~ ERROR E0161
| ^^^^^^^^
error: aborting due to 2 previous errors
Some errors occurred: E0161, E0507.
For more information about an error, try `rustc --explain E0161`.

View file

@ -1,8 +1,27 @@
error: internal compiler error: Accessing `(*_8)` with the kind `Write(Move)` shouldn't be possible
error[E0507]: cannot move out of borrowed content
--> $DIR/issue-20801.rs:36:22
|
LL | let a = unsafe { *mut_ref() };
| ^^^^^^^^^^ cannot move out of borrowed content
error[E0507]: cannot move out of borrowed content
--> $DIR/issue-20801.rs:39:22
|
LL | let b = unsafe { *imm_ref() };
| ^^^^^^^^^^ cannot move out of borrowed content
error[E0507]: cannot move out of borrowed content
--> $DIR/issue-20801.rs:42:22
|
LL | let c = unsafe { *mut_ptr() };
| ^^^^^^^^^^ cannot move out of borrowed content
error[E0507]: cannot move out of borrowed content
--> $DIR/issue-20801.rs:45:22
|
LL | let d = unsafe { *const_ptr() };
| ^^^^^^^^^^^^
| ^^^^^^^^^^^^ cannot move out of borrowed content
error: aborting due to previous error
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0507`.

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-test currently ICEs when using NLL (#52416)
// We used to ICE when moving out of a `*mut T` or `*const T`.
struct T(u8);

View file

@ -1,9 +1,3 @@
error[E0508]: cannot move out of type `[u8]`, a non-copy slice
--> $DIR/issue-30355.rs:15:8
|
LL | &X(*Y)
| ^^ cannot move out of here
error[E0161]: cannot move a value of type X: the size of X cannot be statically determined
--> $DIR/issue-30355.rs:15:6
|
@ -16,6 +10,12 @@ error[E0161]: cannot move a value of type [u8]: the size of [u8] cannot be stati
LL | &X(*Y)
| ^^
error[E0508]: cannot move out of type `[u8]`, a non-copy slice
--> $DIR/issue-30355.rs:15:8
|
LL | &X(*Y)
| ^^ cannot move out of here
error: aborting due to 3 previous errors
Some errors occurred: E0161, E0508.

View file

@ -1,8 +1,8 @@
error[E0507]: cannot move out of borrowed content
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/issue-4335.rs:16:20
|
LL | id(Box::new(|| *v))
| ^^ cannot move out of borrowed content
| ^^ cannot move out of captured variable in an `FnMut` closure
error[E0597]: `v` does not live long enough
--> $DIR/issue-4335.rs:16:17

View file

@ -28,11 +28,11 @@ LL | fn test4(f: &Test) {
LL | f.f.call_mut(())
| ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable
error[E0507]: cannot move out of borrowed content
error[E0507]: cannot move out of captured variable in an `FnMut` closure
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:66:13
|
LL | foo(f);
| ^ cannot move out of borrowed content
| ^ cannot move out of captured variable in an `FnMut` closure
error[E0505]: cannot move out of `f` because it is borrowed
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:65:16