E0421: Unknown enum type
| Code | Category | Stability |
|---|---|---|
E0421 | Struct and enum | Permanent |
Explanation
An enum variant pattern names an enum type that cannot be resolved in that pattern's scope. This diagnostic is specific to enum-pattern lookup; an unresolved bare name in a value expression follows ordinary undefined-name diagnostics instead.
Likely cause
The pattern's enum name is misspelled, is not visible in the current module, or names a different kind of item. Use an enum type available in the pattern's scope and spell its path correctly.
Examples
Unknown enum type in a pattern
enum Color { Red, Blue }
fn main() -> i32 {
let color = Color.Red;
match color {
Shade.Red => 1,
_ => 0,
}
}
Use the resolved enum type
enum Color { Red, Blue }
fn main() -> i32 {
let color = Color.Red;
match color {
Color.Red => 1,
Color.Blue => 0,
}
}