Skip to content

Commit 150599d

Browse files
Add E0530 error explanation
1 parent addb753 commit 150599d

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

src/librustc_resolve/diagnostics.rs

+36-2
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,42 @@ trait Foo {}
12701270
12711271
impl Foo for i32 {}
12721272
```
1273-
"##
1273+
"##,
1274+
1275+
E0530: r##"
1276+
A binding shadowed something it shouldn't.
1277+
1278+
Erroneous code example:
1279+
1280+
```compile_fail,E0530
1281+
static TEST: i32 = 0;
1282+
1283+
let r: (i32, i32) = (0, 0);
1284+
match r {
1285+
TEST => {} // error: match bindings cannot shadow statics
1286+
}
1287+
```
1288+
1289+
To fix this error, just change the binding's name in order to avoid shadowing
1290+
one of the following:
1291+
1292+
* struct name
1293+
* struct/enum variant
1294+
* static
1295+
* const
1296+
* associated const
1297+
1298+
Fixed example:
1299+
1300+
```
1301+
static TEST: i32 = 0;
1302+
1303+
let r: (i32, i32) = (0, 0);
1304+
match r {
1305+
something => {} // ok!
1306+
}
1307+
```
1308+
"##,
12741309

12751310
}
12761311

@@ -1289,7 +1324,6 @@ register_diagnostics! {
12891324
// E0419, merged into 531
12901325
// E0420, merged into 532
12911326
// E0421, merged into 531
1292-
E0530, // X bindings cannot shadow Ys
12931327
E0531, // unresolved pattern path kind `name`
12941328
E0532, // expected pattern path kind, found another pattern path kind
12951329
// E0427, merged into 530

0 commit comments

Comments
 (0)