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

E0484: Duplicate pattern binding

CodeCategoryStability
E0484Struct and enumPermanent

Explanation

Each named payload position in one match pattern introduces a fresh binding. Reusing an identifier in the same pattern would shadow an earlier payload and lose access to that value, so Rue rejects the pattern. The wildcard _ introduces no binding and may repeat.

Likely cause

Two fields of an enum payload pattern were given the same variable name, often when their roles or types are similar. Give every value that must remain accessible a distinct name, or use _ for a payload that may legally be discarded.

Examples

Bind two payloads to one name

enum Shape { Rect(i32, i32) }
fn main() -> i32 {
    match Shape.Rect(20, 22) {
        Shape.Rect(side, side) => side,
    }
}

Bind both payloads distinctly

enum Shape { Rect(i32, i32) }
fn main() -> i32 {
    match Shape.Rect(20, 22) {
        Shape.Rect(width, height) => width + height,
    }
}

References