summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_error_codes/src/error_codes/E0530.md
blob: 60fa711cbed363b458208cae42228331f7936e7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
A binding shadowed something it shouldn't.

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 = 123;
match r {
    TEST => {} // error: name of a static
}
```

Fixed examples:

```
static TEST: i32 = 0;

let r = 123;
match r {
    some_value => {} // ok!
}
```

or

```
const TEST: i32 = 0; // const, not static

let r = 123;
match r {
    TEST => {} // const is ok!
    other_values => {}
}
```