forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#51247 - pnkfelix:issue-51190-report-type-mo…
…ved-from-behind-borrow, r=nikomatsakis NLL: report type moved from behind borrow of array/slice When NLL has illegal move due to borrowed content in an array or slice, provide feedback about why the move wasn't a copy. Drive by: While comparing the resulting `.nll.stderr` files to their old borrowck variants, I noticed that the test for borrowck-vec-pattern-nesting.rs was not signaling some errors under NLL due to the test assuming lexical lifetimes. So I fixed that too. Fix rust-lang#51190
- Loading branch information
Showing
9 changed files
with
105 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
error[E0507]: cannot move out of borrowed content | ||
error[E0508]: cannot move out of type `[Foo]`, a non-copy slice | ||
--> $DIR/borrowck-move-out-of-vec-tail.rs:30:33 | ||
| | ||
LL | &[Foo { string: a }, | ||
| ^ cannot move out of borrowed content | ||
| ^ cannot move out of here | ||
|
||
error[E0507]: cannot move out of borrowed content | ||
error[E0508]: cannot move out of type `[Foo]`, a non-copy slice | ||
--> $DIR/borrowck-move-out-of-vec-tail.rs:34:33 | ||
| | ||
LL | Foo { string: b }] => { | ||
| ^ cannot move out of borrowed content | ||
| ^ cannot move out of here | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0507`. | ||
For more information about this error, try `rustc --explain E0508`. |
77 changes: 51 additions & 26 deletions
77
src/test/ui/borrowck/borrowck-vec-pattern-nesting.nll.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,76 @@ | ||
error[E0507]: cannot move out of borrowed content | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:42:15 | ||
error[E0506]: cannot assign to `vec[..]` because it is borrowed | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:20:13 | ||
| | ||
LL | [box ref _a, _, _] => { | ||
| ------ borrow of `vec[..]` occurs here | ||
LL | //~^ borrow of `vec[..]` occurs here | ||
LL | vec[0] = box 4; //~ ERROR cannot assign | ||
| ^^^^^^ assignment to borrowed `vec[..]` occurs here | ||
LL | //~^ assignment to borrowed `vec[..]` occurs here | ||
LL | _a.use_ref(); | ||
| -- borrow later used here | ||
|
||
error[E0506]: cannot assign to `vec[..]` because it is borrowed | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:33:13 | ||
| | ||
LL | &mut [ref _b..] => { | ||
| ------ borrow of `vec[..]` occurs here | ||
LL | //~^ borrow of `vec[..]` occurs here | ||
LL | vec[0] = box 4; //~ ERROR cannot assign | ||
| ^^^^^^ assignment to borrowed `vec[..]` occurs here | ||
LL | //~^ assignment to borrowed `vec[..]` occurs here | ||
LL | _b.use_ref(); | ||
| -- borrow later used here | ||
|
||
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:44:15 | ||
| | ||
LL | &mut [_a, //~ ERROR cannot move out | ||
| ^^ cannot move out of borrowed content | ||
| ^^ cannot move out of here | ||
|
||
error[E0507]: cannot move out of borrowed content | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:55:13 | ||
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:57:13 | ||
| | ||
LL | let a = vec[0]; //~ ERROR cannot move out | ||
| ^^^^^^ cannot move out of borrowed content | ||
| ^^^^^^ cannot move out of here | ||
|
||
error[E0507]: cannot move out of borrowed content | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:65:10 | ||
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:67:10 | ||
| | ||
LL | _b] => {} | ||
| ^^ cannot move out of borrowed content | ||
| ^^ cannot move out of here | ||
|
||
error[E0507]: cannot move out of borrowed content | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:68:13 | ||
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:70:13 | ||
| | ||
LL | let a = vec[0]; //~ ERROR cannot move out | ||
| ^^^^^^ cannot move out of borrowed content | ||
| ^^^^^^ cannot move out of here | ||
|
||
error[E0507]: cannot move out of borrowed content | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:76:15 | ||
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:78:15 | ||
| | ||
LL | &mut [_a, _b, _c] => {} //~ ERROR cannot move out | ||
| ^^ cannot move out of borrowed content | ||
| ^^ cannot move out of here | ||
|
||
error[E0507]: cannot move out of borrowed content | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:76:19 | ||
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:78:19 | ||
| | ||
LL | &mut [_a, _b, _c] => {} //~ ERROR cannot move out | ||
| ^^ cannot move out of borrowed content | ||
| ^^ cannot move out of here | ||
|
||
error[E0507]: cannot move out of borrowed content | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:76:23 | ||
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:78:23 | ||
| | ||
LL | &mut [_a, _b, _c] => {} //~ ERROR cannot move out | ||
| ^^ cannot move out of borrowed content | ||
| ^^ cannot move out of here | ||
|
||
error[E0507]: cannot move out of borrowed content | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:80:13 | ||
error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice | ||
--> $DIR/borrowck-vec-pattern-nesting.rs:82:13 | ||
| | ||
LL | let a = vec[0]; //~ ERROR cannot move out | ||
| ^^^^^^ cannot move out of borrowed content | ||
| ^^^^^^ cannot move out of here | ||
|
||
error: aborting due to 8 previous errors | ||
error: aborting due to 10 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0507`. | ||
Some errors occurred: E0506, E0508. | ||
For more information about an error, try `rustc --explain E0506`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters