forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
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 rust-lang#87923 - JohnTitor:rollup-id54fyz, r=JohnTitor
Rollup of 14 pull requests Successful merges: - rust-lang#86840 (Constify implementations of `(Try)From` for int types) - rust-lang#87582 (Implement `Printer` for `&mut SymbolPrinter`) - rust-lang#87636 (Added the `Option::unzip()` method) - rust-lang#87700 (Expand explanation of E0530) - rust-lang#87811 (Do not ICE on HIR based WF check when involving lifetimes) - rust-lang#87848 (removed references to parent/child from std::thread documentation) - rust-lang#87854 (correctly handle enum variants in `opt_const_param_of`) - rust-lang#87861 (Fix heading colours in Ayu theme) - rust-lang#87865 (Clarify terms in rustdoc book) - rust-lang#87876 (add `windows` count test) - rust-lang#87880 (Remove duplicate trait bounds in `rustc_data_structures::graph`) - rust-lang#87881 (Proper table row formatting in platform support) - rust-lang#87889 (Use smaller spans when suggesting method call disambiguation) - rust-lang#87895 (typeck: don't suggest inaccessible fields in struct literals and suggest ignoring inaccessible fields in struct patterns) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
32 changed files
with
399 additions
and
132 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,57 @@ | ||
A binding shadowed something it shouldn't. | ||
|
||
Erroneous code example: | ||
A match arm or a variable has a name that is already used by | ||
something else, e.g. | ||
|
||
* struct name | ||
* enum variant | ||
* static | ||
* associated constant | ||
|
||
This error may also happen when an enum variant *with fields* is used | ||
in a pattern, but without its fields. | ||
|
||
```compile_fail | ||
enum Enum { | ||
WithField(i32) | ||
} | ||
use Enum::*; | ||
match WithField(1) { | ||
WithField => {} // error: missing (_) | ||
} | ||
``` | ||
|
||
Match bindings cannot shadow statics: | ||
|
||
```compile_fail,E0530 | ||
static TEST: i32 = 0; | ||
let r: (i32, i32) = (0, 0); | ||
let r = 123; | ||
match r { | ||
TEST => {} // error: match bindings cannot shadow statics | ||
TEST => {} // error: name of a static | ||
} | ||
``` | ||
|
||
To fix this error, just change the binding's name in order to avoid shadowing | ||
one of the following: | ||
Fixed examples: | ||
|
||
* struct name | ||
* struct/enum variant | ||
* static | ||
* const | ||
* associated const | ||
``` | ||
static TEST: i32 = 0; | ||
Fixed example: | ||
let r = 123; | ||
match r { | ||
some_value => {} // ok! | ||
} | ||
``` | ||
|
||
or | ||
|
||
``` | ||
static TEST: i32 = 0; | ||
const TEST: i32 = 0; // const, not static | ||
let r: (i32, i32) = (0, 0); | ||
let r = 123; | ||
match r { | ||
something => {} // ok! | ||
TEST => {} // const is ok! | ||
other_values => {} | ||
} | ||
``` |
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
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.