summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_error_codes/src/error_codes/E0530.md
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_error_codes/src/error_codes/E0530.md')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0530.md57
1 files changed, 57 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0530.md b/compiler/rustc_error_codes/src/error_codes/E0530.md
new file mode 100644
index 000000000..60fa711cb
--- /dev/null
+++ b/compiler/rustc_error_codes/src/error_codes/E0530.md
@@ -0,0 +1,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 => {}
+}
+```