-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #70931 - Dylan-DPC:rollup-f8orcao, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - #70789 (remove false positives of unused_braces) - #70847 (ci: move /var/lib/docker to /mnt on GHA) - #70850 (BTreeMap first last proposal tweaks) - #70876 (Use a `SmallVec` for `Cache::predecessors`.) - #70883 (Clean up E0507 explanation) - #70892 (wf: refactor `compute_trait_ref`) - #70914 (Corrects a typo in rustdoc documentation.) - #70915 (Remove unnecessary TypeFlags::NOMINAL_FLAGS) - #70927 (Clean up E0510 explanation) Failed merges: r? @ghost
- Loading branch information
Showing
14 changed files
with
346 additions
and
273 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
Cannot mutate place in this match guard. | ||
The matched value was assigned in a match guard. | ||
|
||
When matching on a variable it cannot be mutated in the match guards, as this | ||
could cause the match to be non-exhaustive: | ||
Erroneous code example: | ||
|
||
```compile_fail,E0510 | ||
let mut x = Some(0); | ||
match x { | ||
None => (), | ||
Some(_) if { x = None; false } => (), | ||
Some(v) => (), // No longer matches | ||
None => {} | ||
Some(_) if { x = None; false } => {} // error! | ||
Some(_) => {} | ||
} | ||
``` | ||
|
||
When matching on a variable it cannot be mutated in the match guards, as this | ||
could cause the match to be non-exhaustive. | ||
|
||
Here executing `x = None` would modify the value being matched and require us | ||
to go "back in time" to the `None` arm. | ||
to go "back in time" to the `None` arm. To fix it, change the value in the match | ||
arm: | ||
|
||
``` | ||
let mut x = Some(0); | ||
match x { | ||
None => {} | ||
Some(_) => { | ||
x = None; // ok! | ||
} | ||
} | ||
``` |
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
Oops, something went wrong.