Ruta graveolens  ·  notes from a language experiment  ·  cultivated since 2025

E0420: Unknown variant

CodeCategoryStability
E0420Struct and enumPermanent

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
}

References