Skip to content

NLL: change compare-mode=nll to use borrowck=migrate #55134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
@@ -321,20 +321,20 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
continue;
}

let mut err = tcx.struct_span_lint_node(
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
tcx.struct_span_lint_node(
UNUSED_MUT,
vsi[local_decl.source_info.scope].lint_root,
span,
"variable does not need to be mutable",
);
let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);
err.span_suggestion_short_with_applicability(
)
.span_suggestion_short_with_applicability(
mut_span,
"remove this `mut`",
String::new(),
Applicability::MachineApplicable);

err.buffer(&mut mbcx.errors_buffer);
Applicability::MachineApplicable,
)
.emit();
}
}

14 changes: 13 additions & 1 deletion src/test/ui/access-mode-in-closures.nll.stderr
Original file line number Diff line number Diff line change
@@ -13,6 +13,18 @@ note: move occurs because `v` has type `std::vec::Vec<isize>`, which does not im
LL | match *s { sty(v) => v } //~ ERROR cannot move out
| ^

error: aborting due to previous error
error[E0507]: cannot move out of `s.0` which is behind a `&` reference
--> $DIR/access-mode-in-closures.rs:19:24
|
LL | let _foo = unpack(|s| {
| - help: consider changing this to be a mutable reference: `&mut sty`
LL | // Test that `s` is moved here.
LL | match *s { sty(v) => v } //~ ERROR cannot move out
| ^
| |
| cannot move out of `s.0` which is behind a `&` reference
| `s` 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`.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

14 changes: 13 additions & 1 deletion src/test/ui/binop/binop-move-semantics.nll.stderr
Original file line number Diff line number Diff line change
@@ -32,6 +32,18 @@ error[E0507]: cannot move out of borrowed content
LL | *n; //~ ERROR: cannot move out of borrowed content
| ^^ cannot move out of borrowed content

error[E0507]: cannot move out of `*n` which is behind a `&` reference
--> $DIR/binop-move-semantics.rs:42:5
|
LL | let n = &y;
| -- help: consider changing this to be a mutable reference: `&mut y`
...
LL | *n; //~ ERROR: cannot move out of borrowed content
| ^^
| |
| cannot move out of `*n` which is behind a `&` reference
| `n` is a `&` reference, so the data it refers to cannot be moved

error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable
--> $DIR/binop-move-semantics.rs:64:5
|
@@ -62,7 +74,7 @@ LL | | &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also b
| | immutable borrow later used here
| mutable borrow occurs here

error: aborting due to 6 previous errors
error: aborting due to 7 previous errors

Some errors occurred: E0382, E0502, E0507.
For more information about an error, try `rustc --explain E0382`.
8 changes: 6 additions & 2 deletions src/test/ui/borrowck/borrowck-closures-unique.nll.stderr
Original file line number Diff line number Diff line change
@@ -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`.
19 changes: 15 additions & 4 deletions src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr
Original file line number Diff line number Diff line change
@@ -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`.
20 changes: 20 additions & 0 deletions src/test/ui/borrowck/borrowck-fn-in-const-a.ast.nll.stderr
Original file line number Diff line number Diff line change
@@ -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`.
Original file line number Diff line number Diff line change
@@ -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`.
17 changes: 16 additions & 1 deletion src/test/ui/borrowck/borrowck-in-static.nll.stderr
Original file line number Diff line number Diff line change
@@ -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`.
13 changes: 12 additions & 1 deletion src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr
Original file line number Diff line number Diff line change
@@ -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`.
50 changes: 49 additions & 1 deletion src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr
Original file line number Diff line number Diff line change
@@ -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`.
13 changes: 12 additions & 1 deletion src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr
Original file line number Diff line number Diff line change
@@ -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`.
29 changes: 28 additions & 1 deletion src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr
Original file line number Diff line number Diff line change
@@ -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`.
Original file line number Diff line number Diff line change
@@ -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`.
Original file line number Diff line number Diff line change
@@ -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`.
Original file line number Diff line number Diff line change
@@ -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`.
29 changes: 27 additions & 2 deletions src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr
Original file line number Diff line number Diff line change
@@ -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`.
Original file line number Diff line number Diff line change
@@ -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`.

This file was deleted.

11 changes: 10 additions & 1 deletion src/test/ui/borrowck/issue-51415.nll.stderr
Original file line number Diff line number Diff line change
@@ -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`.
14 changes: 0 additions & 14 deletions src/test/ui/borrowck/issue-7573.nll.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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`.
26 changes: 21 additions & 5 deletions src/test/ui/borrowck/mutability-errors.nll.stderr
Original file line number Diff line number Diff line change
@@ -277,41 +277,57 @@ 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,)) {
| - help: consider changing this to be mutable: `mut x`
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,)) {
| - help: consider changing this to be mutable: `mut x`
...
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,)) {
| - help: consider changing this to be mutable: `mut x`
...
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,)) {
| - help: consider changing this to be mutable: `mut x`
...
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`.
12 changes: 0 additions & 12 deletions src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr

This file was deleted.

12 changes: 0 additions & 12 deletions src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr

This file was deleted.

12 changes: 0 additions & 12 deletions src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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`.
11 changes: 10 additions & 1 deletion src/test/ui/by-move-pattern-binding.nll.stderr
Original file line number Diff line number Diff line change
@@ -16,6 +16,15 @@ note: move occurs because `identifier` has type `std::string::String`, which doe
LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move
| ^^^^^^^^^^

error: aborting due to previous error
error[E0507]: cannot move out of data in a `&` reference
--> $DIR/by-move-pattern-binding.rs:26:17
|
LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move
| ^^^^^^^^^^
| |
| 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`.
11 changes: 10 additions & 1 deletion src/test/ui/check-static-values-constraints.nll.stderr
Original file line number Diff line number Diff line change
@@ -58,13 +58,22 @@ LL | let y = { static x: Box<isize> = box 3; x };
| cannot move out of static item
| help: consider borrowing here: `&x`

error[E0507]: cannot move out of immutable static item `x`
--> $DIR/check-static-values-constraints.rs:120:45
|
LL | let y = { static x: Box<isize> = box 3; x };
| ^
| |
| cannot move out of immutable static item `x`
| cannot move

error[E0010]: allocations are not allowed in statics
--> $DIR/check-static-values-constraints.rs:120:38
|
LL | let y = { static x: Box<isize> = box 3; x };
| ^^^^^ allocation not allowed in statics

error: aborting due to 10 previous errors
error: aborting due to 11 previous errors

Some errors occurred: E0010, E0015, E0493, E0507.
For more information about an error, try `rustc --explain E0010`.
54 changes: 0 additions & 54 deletions src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr

This file was deleted.

This file was deleted.

This file was deleted.

7 changes: 5 additions & 2 deletions src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr
Original file line number Diff line number Diff line change
@@ -190,7 +190,7 @@ error: trait bounds other than `Sized` on const fn parameters are unstable
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0716]: temporary value dropped while borrowed
warning[E0716]: temporary value dropped while borrowed
--> $DIR/min_const_fn.rs:142:64
|
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
@@ -199,6 +199,9 @@ LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
| creates a temporary which is freed while still in use
|
= note: borrowed value must be valid for the static lifetime...
= 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: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn.rs:147:41
@@ -218,7 +221,7 @@ error: function pointers in const fn are unstable
LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
| ^^^^

error: aborting due to 36 previous errors
error: aborting due to 35 previous errors

Some errors occurred: E0493, E0716.
For more information about an error, try `rustc --explain E0493`.
7 changes: 5 additions & 2 deletions src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ error: trait bounds other than `Sized` on const fn parameters are unstable
LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
| ^^

error[E0716]: temporary value dropped while borrowed
warning[E0716]: temporary value dropped while borrowed
--> $DIR/min_const_fn_dyn.rs:22:67
|
LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
@@ -19,7 +19,10 @@ LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
| creates a temporary which is freed while still in use
|
= note: borrowed value must be valid for the static lifetime...
= 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 3 previous errors
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0716`.
20 changes: 19 additions & 1 deletion src/test/ui/dst/dst-index.nll.stderr
Original file line number Diff line number Diff line change
@@ -16,13 +16,31 @@ error[E0507]: cannot move out of borrowed content
LL | S[0];
| ^^^^ cannot move out of borrowed content

error[E0507]: cannot move out of data in a `&` reference
--> $DIR/dst-index.rs:41:5
|
LL | S[0];
| ^^^^
| |
| cannot move out of data in a `&` reference
| cannot move

error[E0507]: cannot move out of borrowed content
--> $DIR/dst-index.rs:44:5
|
LL | T[0];
| ^^^^ cannot move out of borrowed content

error: aborting due to 4 previous errors
error[E0507]: cannot move out of data in a `&` reference
--> $DIR/dst-index.rs:44:5
|
LL | T[0];
| ^^^^
| |
| cannot move out of data in a `&` reference
| cannot move

error: aborting due to 6 previous errors

Some errors occurred: E0161, E0507.
For more information about an error, try `rustc --explain E0161`.
22 changes: 21 additions & 1 deletion src/test/ui/dst/dst-rvalue.nll.stderr
Original file line number Diff line number Diff line change
@@ -16,13 +16,33 @@ error[E0507]: cannot move out of borrowed content
LL | let _x: Box<str> = box *"hello world";
| ^^^^^^^^^^^^^^ cannot move out of borrowed content

error[E0507]: cannot move out of data in a `&` reference
--> $DIR/dst-rvalue.rs:16:28
|
LL | let _x: Box<str> = box *"hello world";
| ^^^^^^^^^^^^^^
| |
| cannot move out of data in a `&` reference
| cannot move

error[E0508]: cannot move out of type `[isize]`, a non-copy slice
--> $DIR/dst-rvalue.rs:21:32
|
LL | let _x: Box<[isize]> = box *array;
| ^^^^^^ cannot move out of here

error: aborting due to 4 previous errors
error[E0507]: cannot move out of `*array` which is behind a `&` reference
--> $DIR/dst-rvalue.rs:21:32
|
LL | let array: &[isize] = &[1, 2, 3];
| ---------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3]`
LL | let _x: Box<[isize]> = box *array;
| ^^^^^^
| |
| cannot move out of `*array` which is behind a `&` reference
| `array` is a `&` reference, so the data it refers to cannot be moved

error: aborting due to 6 previous errors

Some errors occurred: E0161, E0507, E0508.
For more information about an error, try `rustc --explain E0161`.
18 changes: 18 additions & 0 deletions src/test/ui/error-codes/E0507.nll.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error[E0507]: cannot move out of borrowed content
--> $DIR/E0507.rs:22:5
|
LL | x.borrow().nothing_is_true(); //~ ERROR E0507
| ^^^^^^^^^^ cannot move out of borrowed content

error[E0507]: cannot move out of data in a `&` reference
--> $DIR/E0507.rs:22:5
|
LL | x.borrow().nothing_is_true(); //~ ERROR E0507
| ^^^^^^^^^^
| |
| 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`.

This file was deleted.

This file was deleted.

This file was deleted.

16 changes: 0 additions & 16 deletions src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr

This file was deleted.

10 changes: 0 additions & 10 deletions src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr

This file was deleted.

This file was deleted.

26 changes: 0 additions & 26 deletions src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/ui/impl-trait/type_parameters_captured.nll.stderr

This file was deleted.

20 changes: 0 additions & 20 deletions src/test/ui/in-band-lifetimes/mismatched.nll.stderr

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/ui/issues/issue-10291.nll.stderr

This file was deleted.

41 changes: 39 additions & 2 deletions src/test/ui/issues/issue-12567.nll.stderr
Original file line number Diff line number Diff line change
@@ -40,6 +40,43 @@ LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
LL | (&[hd1, ..], &[hd2, ..])
| ^^^

error: aborting due to 2 previous errors
error[E0507]: cannot move out of data in a `&` reference
--> $DIR/issue-12567.rs:16:17
|
LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
| ^^
| |
| cannot move out of data in a `&` reference
| cannot move

error[E0507]: cannot move out of data in a `&` reference
--> $DIR/issue-12567.rs:16:31
|
LL | (&[], &[hd, ..]) | (&[hd, ..], &[])
| ^^
| |
| cannot move out of data in a `&` reference
| cannot move

error[E0507]: cannot move out of data in a `&` reference
--> $DIR/issue-12567.rs:20:12
|
LL | (&[hd1, ..], &[hd2, ..])
| ^^^
| |
| cannot move out of data in a `&` reference
| cannot move

error[E0507]: cannot move out of data in a `&` reference
--> $DIR/issue-12567.rs:20:24
|
LL | (&[hd1, ..], &[hd2, ..])
| ^^^
| |
| cannot move out of data in a `&` reference
| cannot move

error: aborting due to 6 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`.
12 changes: 0 additions & 12 deletions src/test/ui/issues/issue-13058.nll.stderr

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/ui/issues/issue-15034.nll.stderr

This file was deleted.

10 changes: 0 additions & 10 deletions src/test/ui/issues/issue-16683.nll.stderr

This file was deleted.

11 changes: 10 additions & 1 deletion src/test/ui/issues/issue-17718-static-move.nll.stderr
Original file line number Diff line number Diff line change
@@ -7,6 +7,15 @@ LL | let _a = FOO; //~ ERROR: cannot move out of static item
| cannot move out of static item
| help: consider borrowing here: `&FOO`

error: aborting due to previous error
error[E0507]: cannot move out of immutable static item `FOO`
--> $DIR/issue-17718-static-move.rs:16:14
|
LL | let _a = FOO; //~ ERROR: cannot move out of static item
| ^^^
| |
| cannot move out of immutable static item `FOO`
| cannot move

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0507`.
19 changes: 0 additions & 19 deletions src/test/ui/issues/issue-17728.nll.stderr

This file was deleted.

10 changes: 0 additions & 10 deletions src/test/ui/issues/issue-17758.nll.stderr

This file was deleted.

20 changes: 19 additions & 1 deletion src/test/ui/issues/issue-20801.nll.stderr
Original file line number Diff line number Diff line change
@@ -16,6 +16,15 @@ LL | let b = unsafe { *imm_ref() };
| cannot move out of borrowed content
| help: consider removing the `*`: `imm_ref()`

error[E0507]: cannot move out of data in a `&` reference
--> $DIR/issue-20801.rs:39:22
|
LL | let b = unsafe { *imm_ref() };
| ^^^^^^^^^^
| |
| cannot move out of data in a `&` reference
| cannot move

error[E0507]: cannot move out of dereference of raw pointer
--> $DIR/issue-20801.rs:42:22
|
@@ -34,6 +43,15 @@ LL | let d = unsafe { *const_ptr() };
| cannot move out of dereference of raw pointer
| help: consider removing the `*`: `const_ptr()`

error: aborting due to 4 previous errors
error[E0507]: cannot move out of data in a `*const` pointer
--> $DIR/issue-20801.rs:45:22
|
LL | let d = unsafe { *const_ptr() };
| ^^^^^^^^^^^^
| |
| cannot move out of data in a `*const` pointer
| cannot move

error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0507`.
13 changes: 12 additions & 1 deletion src/test/ui/issues/issue-2590.nll.stderr
Original file line number Diff line number Diff line change
@@ -4,6 +4,17 @@ error[E0507]: cannot move out of borrowed content
LL | self.tokens //~ ERROR cannot move out of borrowed content
| ^^^^^^^^^^^ cannot move out of borrowed content

error: aborting due to previous error
error[E0507]: cannot move out of `self.tokens` which is behind a `&` reference
--> $DIR/issue-2590.rs:22:9
|
LL | fn parse(&self) -> Vec<isize> {
| ----- help: consider changing this to be a mutable reference: `&mut self`
LL | self.tokens //~ ERROR cannot move out of borrowed content
| ^^^^^^^^^^^
| |
| cannot move out of `self.tokens` which is behind a `&` reference
| `self` 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`.
9 changes: 0 additions & 9 deletions src/test/ui/issues/issue-26217.nll.stderr

This file was deleted.

13 changes: 11 additions & 2 deletions src/test/ui/issues/issue-30355.nll.stderr
Original file line number Diff line number Diff line change
@@ -16,7 +16,16 @@ error[E0508]: cannot move out of type `[u8]`, a non-copy slice
LL | &X(*Y)
| ^^ cannot move out of here

error: aborting due to 3 previous errors
error[E0507]: cannot move out of data in a `&` reference
--> $DIR/issue-30355.rs:15:8
|
LL | &X(*Y)
| ^^
| |
| cannot move out of data in a `&` reference
| cannot move

error: aborting due to 4 previous errors

Some errors occurred: E0161, E0508.
Some errors occurred: E0161, E0507, E0508.
For more information about an error, try `rustc --explain E0161`.
21 changes: 0 additions & 21 deletions src/test/ui/issues/issue-40288-2.nll.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -7,6 +7,15 @@ LL | let e = f.v[0]; //~ ERROR cannot move out of indexed content
| cannot move out of borrowed content
| help: consider borrowing here: `&f.v[0]`

error: aborting due to previous error
error[E0507]: cannot move out of data in a `&` reference
--> $DIR/issue-40402-1.rs:19:13
|
LL | let e = f.v[0]; //~ ERROR cannot move out of indexed content
| ^^^^^^
| |
| 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`.
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
error[E0507]: cannot move out of data in a `&` reference
--> $DIR/issue-40402-2.rs:15:10
|
LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content
| ^
| |
| cannot move out of data in a `&` reference
| cannot move

error[E0507]: cannot move out of data in a `&` reference
--> $DIR/issue-40402-2.rs:15:13
|
LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content
| ^
| |
| cannot move out of data in a `&` reference
| cannot move

error[E0507]: cannot move out of borrowed content
--> $DIR/issue-40402-2.rs:15:18
|
@@ -15,6 +33,6 @@ note: move occurs because these variables have types that don't implement the `C
LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content
| ^ ^

error: aborting due to previous error
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0507`.
11 changes: 10 additions & 1 deletion src/test/ui/issues/issue-40510-1.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: captured variable cannot escape `FnMut` closure body
warning: captured variable cannot escape `FnMut` closure body
--> $DIR/issue-40510-1.rs:18:9
|
LL | || {
@@ -8,6 +8,15 @@ LL | &mut x
|
= 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: compilation successful
--> $DIR/issue-40510-1.rs:23:1
|
LL | fn main() {} //~ ERROR compilation successful
| ^^^^^^^^^^^^

error: aborting due to previous error

11 changes: 10 additions & 1 deletion src/test/ui/issues/issue-40510-3.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: captured variable cannot escape `FnMut` closure body
warning: captured variable cannot escape `FnMut` closure body
--> $DIR/issue-40510-3.rs:18:9
|
LL | || {
@@ -10,6 +10,15 @@ 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: compilation successful
--> $DIR/issue-40510-3.rs:25:1
|
LL | fn main() {} //~ ERROR compilation successful
| ^^^^^^^^^^^^

error: aborting due to previous error

11 changes: 10 additions & 1 deletion src/test/ui/issues/issue-4335.nll.stderr
Original file line number Diff line number Diff line change
@@ -6,6 +6,15 @@ LL | fn f<'r, T>(v: &'r T) -> Box<FnMut() -> T + 'r> {
LL | id(Box::new(|| *v))
| ^^ cannot move out of captured variable in an `FnMut` closure

error[E0507]: cannot move out of `*v` which is behind a `&` reference
--> $DIR/issue-4335.rs:16:20
|
LL | id(Box::new(|| *v))
| ^^
| |
| cannot move out of `*v` which is behind a `&` reference
| cannot move

error[E0597]: `v` does not live long enough
--> $DIR/issue-4335.rs:16:21
|
@@ -23,7 +32,7 @@ note: borrowed value must be valid for the lifetime 'r as defined on the functio
LL | fn f<'r, T>(v: &'r T) -> Box<FnMut() -> T + 'r> {
| ^^

error: aborting due to 2 previous errors
error: aborting due to 3 previous errors

Some errors occurred: E0507, E0597.
For more information about an error, try `rustc --explain E0507`.
17 changes: 16 additions & 1 deletion src/test/ui/issues/issue-49824.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: captured variable cannot escape `FnMut` closure body
warning: captured variable cannot escape `FnMut` closure body
--> $DIR/issue-49824.rs:22:9
|
LL | || {
@@ -10,6 +10,21 @@ 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: compilation successful
--> $DIR/issue-49824.rs:18:1
|
LL | / fn main() {
LL | | //~^ compilation successful
LL | | let mut x = 0;
LL | | || {
... |
LL | | };
LL | | }
| |_^

error: aborting due to previous error

13 changes: 0 additions & 13 deletions src/test/ui/issues/issue-52213.nll.stderr

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/ui/issues/issue-52533-1.nll.stderr

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/ui/issues/issue-52533.nll.stderr

This file was deleted.

63 changes: 0 additions & 63 deletions src/test/ui/kindck/kindck-impl-type-params.nll.stderr

This file was deleted.

32 changes: 0 additions & 32 deletions src/test/ui/kindck/kindck-send-object1.nll.stderr

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions src/test/ui/lub-if.nll.stderr

This file was deleted.

20 changes: 0 additions & 20 deletions src/test/ui/lub-match.nll.stderr

This file was deleted.

12 changes: 0 additions & 12 deletions src/test/ui/match/match-ref-mut-invariance.nll.stderr

This file was deleted.

13 changes: 0 additions & 13 deletions src/test/ui/match/match-ref-mut-let-invariance.nll.stderr

This file was deleted.

14 changes: 13 additions & 1 deletion src/test/ui/moves/moves-based-on-type-block-bad.nll.stderr
Original file line number Diff line number Diff line change
@@ -16,6 +16,18 @@ note: move occurs because `x` has type `std::boxed::Box<isize>`, which does not
LL | box E::Bar(x) => println!("{}", x.to_string()),
| ^

error: aborting due to previous error
error[E0507]: cannot move out of `hellothere.x.0` which is behind a `&` reference
--> $DIR/moves-based-on-type-block-bad.rs:37:28
|
LL | f(&s, |hellothere| {
| ---------- help: consider changing this to be a mutable reference: `&mut S`
...
LL | box E::Bar(x) => println!("{}", x.to_string()),
| ^
| |
| cannot move out of `hellothere.x.0` which is behind a `&` reference
| `hellothere` 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`.
Original file line number Diff line number Diff line change
@@ -6,6 +6,21 @@ LL | let i = box 3;
LL | let _f = to_fn(|| test(i)); //~ ERROR cannot move out
| ^ cannot move out of captured variable in an `Fn` closure

error: aborting due to previous error
error[E0507]: cannot move out of `i`, as it is a captured variable in a `Fn` closure
--> $DIR/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:21:28
|
LL | let _f = to_fn(|| test(i)); //~ ERROR cannot move out
| ^
| |
| cannot move out of `i`, as it is a captured variable in a `Fn` closure
| cannot move
|
help: consider changing this to accept closures that implement `FnMut`
--> $DIR/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:21:20
|
LL | let _f = to_fn(|| test(i)); //~ ERROR cannot move out
| ^^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0507`.
72 changes: 71 additions & 1 deletion src/test/ui/nll/cannot-move-block-spans.nll.stderr
Original file line number Diff line number Diff line change
@@ -7,6 +7,17 @@ LL | let x = { *r }; //~ ERROR
| cannot move out of borrowed content
| help: consider removing the `*`: `r`

error[E0507]: cannot move out of `*r` which is behind a `&` reference
--> $DIR/cannot-move-block-spans.rs:15:15
|
LL | pub fn deref(r: &String) {
| ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
LL | let x = { *r }; //~ ERROR
| ^^
| |
| cannot move out of `*r` which is behind a `&` reference
| `r` is a `&` reference, so the data it refers to cannot be moved

error[E0507]: cannot move out of borrowed content
--> $DIR/cannot-move-block-spans.rs:16:22
|
@@ -16,6 +27,18 @@ LL | let y = unsafe { *r }; //~ ERROR
| cannot move out of borrowed content
| help: consider removing the `*`: `r`

error[E0507]: cannot move out of `*r` which is behind a `&` reference
--> $DIR/cannot-move-block-spans.rs:16:22
|
LL | pub fn deref(r: &String) {
| ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
LL | let x = { *r }; //~ ERROR
LL | let y = unsafe { *r }; //~ ERROR
| ^^
| |
| cannot move out of `*r` which is behind a `&` reference
| `r` is a `&` reference, so the data it refers to cannot be moved

error[E0507]: cannot move out of borrowed content
--> $DIR/cannot-move-block-spans.rs:17:26
|
@@ -25,6 +48,18 @@ LL | let z = loop { break *r; }; //~ ERROR
| cannot move out of borrowed content
| help: consider removing the `*`: `r`

error[E0507]: cannot move out of `*r` which is behind a `&` reference
--> $DIR/cannot-move-block-spans.rs:17:26
|
LL | pub fn deref(r: &String) {
| ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
...
LL | let z = loop { break *r; }; //~ ERROR
| ^^
| |
| cannot move out of `*r` which is behind a `&` reference
| `r` is a `&` reference, so the data it refers to cannot be moved

error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array
--> $DIR/cannot-move-block-spans.rs:21:15
|
@@ -61,6 +96,17 @@ LL | let x = { let mut u = 0; u += 1; *r }; //~ ERROR
| cannot move out of borrowed content
| help: consider removing the `*`: `r`

error[E0507]: cannot move out of `*r` which is behind a `&` reference
--> $DIR/cannot-move-block-spans.rs:27:38
|
LL | pub fn additional_statement_cases(r: &String) {
| ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
LL | let x = { let mut u = 0; u += 1; *r }; //~ ERROR
| ^^
| |
| cannot move out of `*r` which is behind a `&` reference
| `r` is a `&` reference, so the data it refers to cannot be moved

error[E0507]: cannot move out of borrowed content
--> $DIR/cannot-move-block-spans.rs:28:45
|
@@ -70,6 +116,18 @@ LL | let y = unsafe { let mut u = 0; u += 1; *r }; //~ ERROR
| cannot move out of borrowed content
| help: consider removing the `*`: `r`

error[E0507]: cannot move out of `*r` which is behind a `&` reference
--> $DIR/cannot-move-block-spans.rs:28:45
|
LL | pub fn additional_statement_cases(r: &String) {
| ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
LL | let x = { let mut u = 0; u += 1; *r }; //~ ERROR
LL | let y = unsafe { let mut u = 0; u += 1; *r }; //~ ERROR
| ^^
| |
| cannot move out of `*r` which is behind a `&` reference
| `r` is a `&` reference, so the data it refers to cannot be moved

error[E0507]: cannot move out of borrowed content
--> $DIR/cannot-move-block-spans.rs:29:49
|
@@ -79,7 +137,19 @@ LL | let z = loop { let mut u = 0; u += 1; break *r; u += 2; }; //~ ERROR
| cannot move out of borrowed content
| help: consider removing the `*`: `r`

error: aborting due to 9 previous errors
error[E0507]: cannot move out of `*r` which is behind a `&` reference
--> $DIR/cannot-move-block-spans.rs:29:49
|
LL | pub fn additional_statement_cases(r: &String) {
| ------- help: consider changing this to be a mutable reference: `&mut std::string::String`
...
LL | let z = loop { let mut u = 0; u += 1; break *r; u += 2; }; //~ ERROR
| ^^
| |
| cannot move out of `*r` which is behind a `&` reference
| `r` is a `&` reference, so the data it refers to cannot be moved

error: aborting due to 15 previous errors

Some errors occurred: E0507, E0508.
For more information about an error, try `rustc --explain E0507`.
30 changes: 29 additions & 1 deletion src/test/ui/nll/match-guards-always-borrow.ast.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
error[E0507]: cannot move out of borrowed content
warning[E0507]: cannot move out of borrowed content
--> $DIR/match-guards-always-borrow.rs:23:13
|
LL | (|| { let bar = foo; bar.take() })();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
|
= 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.

warning[E0507]: cannot move out of `foo`, as it is immutable for the pattern guard
--> $DIR/match-guards-always-borrow.rs:23:13
|
LL | (|| { let bar = foo; bar.take() })();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| cannot move out of `foo`, as it is immutable for the pattern guard
| cannot move
|
= note: variables bound in patterns are immutable until the end of the pattern guard
= 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: compilation successful
--> $DIR/match-guards-always-borrow.rs:57:1
|
LL | / fn main() { //[ast]~ ERROR compilation successful
LL | | should_reject_destructive_mutate_in_guard();
LL | | allow_mutate_in_arm_body();
LL | | allow_move_into_arm_body();
LL | | }
| |_^

error: aborting due to previous error

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions src/test/ui/regions/region-object-lifetime-2.nll.stderr

This file was deleted.

12 changes: 0 additions & 12 deletions src/test/ui/regions/region-object-lifetime-4.nll.stderr

This file was deleted.

38 changes: 0 additions & 38 deletions src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr

This file was deleted.

10 changes: 0 additions & 10 deletions src/test/ui/regions/regions-addr-of-self.nll.stderr

This file was deleted.

Loading