Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ecb6686
Expand explanation of E0530
kornelski Aug 2, 2021
2a56a4f
removed references to parent/child from std::thread documentation
godmar Aug 7, 2021
eefd790
impl const From<num> for num
usbalbin Dec 27, 2020
09928a9
Add tests
usbalbin Mar 13, 2021
c8bf5ed
Add test for int to float
usbalbin Aug 7, 2021
d777cb8
less opt in const param of
BoxyUwU Aug 7, 2021
5f61271
fmt
BoxyUwU Aug 7, 2021
9a78489
Fix heading colours in Ayu theme
tsoutsman Aug 8, 2021
a4af040
Clarify terms in rustdoc book
tsoutsman Aug 8, 2021
f93cbed
Do not ICE on HIR based WF check when involving lifetimes
estebank Aug 6, 2021
cb19d83
Proper table row formatting in platform support
badboy Aug 9, 2021
bc4ce79
Added the `Option::unzip()` method
Kixiron Jul 30, 2021
eea3520
Added some basic tests for `Option::unzip()` and `Option::zip()` (I n…
Kixiron Jul 30, 2021
9d8081e
Enabled unzip_option feature for core tests & unzip docs
Kixiron Jul 31, 2021
ab2c590
Added tracking issue to unstable attribute
Kixiron Aug 5, 2021
c046d62
Use a more accurate span on assoc types WF checks
estebank Aug 6, 2021
33186e4
Rollup merge of #86840 - usbalbin:const_from, r=oli-obk
JohnTitor Aug 10, 2021
28e84e4
Rollup merge of #87636 - Kixiron:unzip-option, r=scottmcm
JohnTitor Aug 10, 2021
c9f68d2
Rollup merge of #87700 - kornelski:e530text, r=oli-obk
JohnTitor Aug 10, 2021
5709f22
Rollup merge of #87811 - estebank:issue-87549, r=oli-obk
JohnTitor Aug 10, 2021
304c5b9
Rollup merge of #87819 - estebank:assoc-type-span, r=jackh726
JohnTitor Aug 10, 2021
dd31fc3
Rollup merge of #87848 - godmar:@godmar/thread-join-documentation-fix…
JohnTitor Aug 10, 2021
be65d77
Rollup merge of #87854 - BoxyUwU:var-None, r=oli-obk
JohnTitor Aug 10, 2021
05d6699
Rollup merge of #87861 - tsoutsman:patch-1, r=GuillaumeGomez
JohnTitor Aug 10, 2021
91505d7
Rollup merge of #87865 - tsoutsman:master, r=GuillaumeGomez
JohnTitor Aug 10, 2021
74c27ab
Rollup merge of #87881 - badboy:platform-support-formatting, r=ehuss
JohnTitor Aug 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Expand explanation of E0530
  • Loading branch information
kornelski committed Aug 3, 2021
commit ecb668691424595f6e302095c3078de2f89bf435
53 changes: 39 additions & 14 deletions compiler/rustc_error_codes/src/error_codes/E0530.md
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 => {}
}
```