Skip to content

Commit d6b9e0b

Browse files
Add E0417 error explanation
1 parent 8d91bbd commit d6b9e0b

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/librustc_resolve/diagnostics.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,33 @@ impl Bar {
397397
```
398398
"##,
399399

400+
E0417: r##"
401+
A static variable was referenced in a pattern. Example of erroneous code:
402+
403+
```
404+
static FOO : i32 = 0;
405+
406+
match 0 {
407+
FOO => {} // error: static variables cannot be referenced in a
408+
// pattern, use a `const` instead
409+
_ => {}
410+
}
411+
```
412+
413+
Compiler needs to know the pattern value at compile's time, which is
414+
not possible with a `static` variable. So please verify you didn't
415+
misspell the variable's name or use a `const` instead. Example:
416+
417+
```
418+
const FOO : i32 = 0;
419+
420+
match 0 {
421+
FOO => {} // ok!
422+
_ => {}
423+
}
424+
```
425+
"##,
426+
400427
E0428: r##"
401428
A type or module has been defined more than once. Example of erroneous
402429
code:
@@ -448,8 +475,6 @@ register_diagnostics! {
448475
E0414, // only irrefutable patterns allowed here
449476
E0415, // identifier is bound more than once in this parameter list
450477
E0416, // identifier is bound more than once in the same pattern
451-
E0417, // static variables cannot be referenced in a pattern, use a
452-
// `const` instead
453478
E0418, // is not an enum variant, struct or const
454479
E0419, // unresolved enum variant, struct or const
455480
E0420, // is not an associated const

0 commit comments

Comments
 (0)