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

E0419: Duplicate variant

CodeCategoryStability
E0419Struct and enumPermanent

Explanation

An enum declaration defines the same variant name more than once. Variant names identify the alternatives of one enum and must be unique within that enum.

Likely cause

A variant was copied, generated twice, or renamed to a name already used in the same enum. Remove the duplicate or give every variant in the enum a distinct name; another enum may independently use the same variant name.

Examples

Duplicate variant name

enum Color { Red, Green, Red }
fn main() -> i32 { 0 }

Use unique variant names

enum Color { Red, Green, Blue }
fn main() -> i32 {
    let color = Color.Blue;
    0
}

References