E0420: Unknown variant
| Code | Category | Stability |
|---|---|---|
E0420 | Struct and enum | Permanent |
Explanation
An enum variant expression or pattern names a variant that is not declared by the resolved enum type.
Likely cause
The variant name is misspelled, belongs to another enum, or was removed or renamed while uses remained. Check the variants declared by the named enum and use the exact matching name.
Examples
Unknown variant on a known enum
enum Color { Red, Green, Blue }
fn main() -> i32 {
let color = Color.Yellow;
0
}
Use a declared variant
enum Color { Red, Green, Blue }
fn main() -> i32 {
let color = Color.Green;
0
}