about summary refs log tree commit diff
path: root/compiler/rustc_error_codes/src
diff options
context:
space:
mode:
authorKornel <kornel@cloudflare.com>2021-08-02 15:52:22 +0100
committerKornel <kornel@cloudflare.com>2021-08-03 11:11:17 +0100
commitecb668691424595f6e302095c3078de2f89bf435 (patch)
treee858391482a45a79a2f3468db16dc7176900cfa6 /compiler/rustc_error_codes/src
parente91405b9d5c8dabb3e488bafb314147f1050f9b9 (diff)
downloadrust-ecb668691424595f6e302095c3078de2f89bf435.tar.gz
rust-ecb668691424595f6e302095c3078de2f89bf435.zip
Expand explanation of E0530
Diffstat (limited to 'compiler/rustc_error_codes/src')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0530.md53
1 files changed, 39 insertions, 14 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0530.md b/compiler/rustc_error_codes/src/error_codes/E0530.md
index 502f674fc1d..60fa711cbed 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0530.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0530.md
@@ -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 => {}
 }
 ```