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#55696 - davidtwco:issue-55675, r=pnkfelix
NLL Diagnostic Review 3: Missing errors for borrows of union fields Fixes rust-lang#55675. This PR modifies a test to make it more robust (it also fixes indentation on a doc comment, but that's not the point of the PR). See the linked issue for details. r? @pnkfelix
- Loading branch information
Showing
4 changed files
with
75 additions
and
36 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
47 changes: 39 additions & 8 deletions
47
src/test/ui/union/union-borrow-move-parent-sibling.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,33 +1,64 @@ | ||
error[E0502]: cannot borrow `u.y` as immutable because it is also borrowed as mutable | ||
--> $DIR/union-borrow-move-parent-sibling.rs:25:13 | ||
| | ||
LL | let a = &mut u.x.0; | ||
| ---------- mutable borrow occurs here | ||
LL | let b = &u.y; //~ ERROR cannot borrow `u.y` | ||
| ^^^^ immutable borrow occurs here | ||
LL | use_borrow(a); | ||
| - mutable borrow later used here | ||
|
||
error[E0382]: use of moved value: `u` | ||
--> $DIR/union-borrow-move-parent-sibling.rs:29:13 | ||
--> $DIR/union-borrow-move-parent-sibling.rs:32:13 | ||
| | ||
LL | let a = u.x.0; | ||
| ----- value moved here | ||
LL | let a = u.y; //~ ERROR use of moved value: `u.y` | ||
LL | let b = u.y; //~ ERROR use of moved value: `u.y` | ||
| ^^^ value used here after move | ||
| | ||
= note: move occurs because `u` has type `U`, which does not implement the `Copy` trait | ||
|
||
error[E0502]: cannot borrow `u.y` as immutable because it is also borrowed as mutable | ||
--> $DIR/union-borrow-move-parent-sibling.rs:38:13 | ||
| | ||
LL | let a = &mut (u.x.0).0; | ||
| -------------- mutable borrow occurs here | ||
LL | let b = &u.y; //~ ERROR cannot borrow `u.y` | ||
| ^^^^ immutable borrow occurs here | ||
LL | use_borrow(a); | ||
| - mutable borrow later used here | ||
|
||
error[E0382]: use of moved value: `u` | ||
--> $DIR/union-borrow-move-parent-sibling.rs:41:13 | ||
--> $DIR/union-borrow-move-parent-sibling.rs:45:13 | ||
| | ||
LL | let a = (u.x.0).0; | ||
| --------- value moved here | ||
LL | let a = u.y; //~ ERROR use of moved value: `u.y` | ||
LL | let b = u.y; //~ ERROR use of moved value: `u.y` | ||
| ^^^ value used here after move | ||
| | ||
= note: move occurs because `u` has type `U`, which does not implement the `Copy` trait | ||
|
||
error[E0502]: cannot borrow `u.x` as immutable because it is also borrowed as mutable | ||
--> $DIR/union-borrow-move-parent-sibling.rs:51:13 | ||
| | ||
LL | let a = &mut *u.y; | ||
| --------- mutable borrow occurs here | ||
LL | let b = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) | ||
| ^^^^ immutable borrow occurs here | ||
LL | use_borrow(a); | ||
| - mutable borrow later used here | ||
|
||
error[E0382]: use of moved value: `u` | ||
--> $DIR/union-borrow-move-parent-sibling.rs:53:13 | ||
--> $DIR/union-borrow-move-parent-sibling.rs:58:13 | ||
| | ||
LL | let a = *u.y; | ||
| ---- value moved here | ||
LL | let a = u.x; //~ ERROR use of moved value: `u.x` | ||
LL | let b = u.x; //~ ERROR use of moved value: `u.x` | ||
| ^^^ value used here after move | ||
| | ||
= note: move occurs because `u` has type `U`, which does not implement the `Copy` trait | ||
|
||
error: aborting due to 3 previous errors | ||
error: aborting due to 6 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0382`. | ||
Some errors occurred: E0382, E0502. | ||
For more information about an error, try `rustc --explain E0382`. |
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
27 changes: 15 additions & 12 deletions
27
src/test/ui/union/union-borrow-move-parent-sibling.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