-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 #117343 - Nadrieril:cleanup_check_match, r=davidtwco
Cleanup `rustc_mir_build/../check_match.rs` The file had become pretty unwieldy, with a fair amount of duplication. As a bonus, I discovered that we weren't running some pattern checks in if-let chains. I recommend looking commit-by-commit. The last commit is a whim, I think it makes more sense that way but I don't hold this opinion strongly.
- Loading branch information
Showing
28 changed files
with
749 additions
and
627 deletions.
There are no files selected for viewing
834 changes: 400 additions & 434 deletions
834
compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#![feature(if_let_guard, let_chains)] | ||
|
||
fn main() { | ||
let mut x = Some(String::new()); | ||
let ref mut y @ ref mut z = x; | ||
//~^ ERROR: mutable more than once | ||
let Some(ref mut y @ ref mut z) = x else { return }; | ||
//~^ ERROR: mutable more than once | ||
if let Some(ref mut y @ ref mut z) = x {} | ||
//~^ ERROR: mutable more than once | ||
if let Some(ref mut y @ ref mut z) = x && true {} | ||
//~^ ERROR: mutable more than once | ||
while let Some(ref mut y @ ref mut z) = x {} | ||
//~^ ERROR: mutable more than once | ||
while let Some(ref mut y @ ref mut z) = x && true {} | ||
//~^ ERROR: mutable more than once | ||
match x { | ||
ref mut y @ ref mut z => {} //~ ERROR: mutable more than once | ||
} | ||
match () { | ||
() if let Some(ref mut y @ ref mut z) = x => {} //~ ERROR: mutable more than once | ||
_ => {} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
error: cannot borrow value as mutable more than once at a time | ||
--> $DIR/conflicting_bindings.rs:5:9 | ||
| | ||
LL | let ref mut y @ ref mut z = x; | ||
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here | ||
| | | ||
| value is mutably borrowed by `y` here | ||
|
||
error: cannot borrow value as mutable more than once at a time | ||
--> $DIR/conflicting_bindings.rs:7:14 | ||
| | ||
LL | let Some(ref mut y @ ref mut z) = x else { return }; | ||
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here | ||
| | | ||
| value is mutably borrowed by `y` here | ||
|
||
error: cannot borrow value as mutable more than once at a time | ||
--> $DIR/conflicting_bindings.rs:9:17 | ||
| | ||
LL | if let Some(ref mut y @ ref mut z) = x {} | ||
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here | ||
| | | ||
| value is mutably borrowed by `y` here | ||
|
||
error: cannot borrow value as mutable more than once at a time | ||
--> $DIR/conflicting_bindings.rs:11:17 | ||
| | ||
LL | if let Some(ref mut y @ ref mut z) = x && true {} | ||
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here | ||
| | | ||
| value is mutably borrowed by `y` here | ||
|
||
error: cannot borrow value as mutable more than once at a time | ||
--> $DIR/conflicting_bindings.rs:13:20 | ||
| | ||
LL | while let Some(ref mut y @ ref mut z) = x {} | ||
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here | ||
| | | ||
| value is mutably borrowed by `y` here | ||
|
||
error: cannot borrow value as mutable more than once at a time | ||
--> $DIR/conflicting_bindings.rs:15:20 | ||
| | ||
LL | while let Some(ref mut y @ ref mut z) = x && true {} | ||
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here | ||
| | | ||
| value is mutably borrowed by `y` here | ||
|
||
error: cannot borrow value as mutable more than once at a time | ||
--> $DIR/conflicting_bindings.rs:18:9 | ||
| | ||
LL | ref mut y @ ref mut z => {} | ||
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here | ||
| | | ||
| value is mutably borrowed by `y` here | ||
|
||
error: cannot borrow value as mutable more than once at a time | ||
--> $DIR/conflicting_bindings.rs:21:24 | ||
| | ||
LL | () if let Some(ref mut y @ ref mut z) = x => {} | ||
| ^^^^^^^^^ --------- value is mutably borrowed by `z` here | ||
| | | ||
| value is mutably borrowed by `y` here | ||
|
||
error: aborting due to 8 previous errors | ||
|
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
Oops, something went wrong.