Error code E0530

A binding shadowed something it shouldn’t.

A match arm or a variable has a name that is already used by something else, e.g.

This error may also happen when an enum variant with fields is used in a pattern, but without its fields.

enum Enum {
    WithField(i32)
}

use Enum::*;
match WithField(1) {
    WithField => {} // error: missing (_)
}
Run

Match bindings cannot shadow statics:

static TEST: i32 = 0;

let r = 123;
match r {
    TEST => {} // error: name of a static
}
Run

Fixed examples:

static TEST: i32 = 0;

let r = 123;
match r {
    some_value => {} // ok!
}
Run

or

const TEST: i32 = 0; // const, not static

let r = 123;
match r {
    TEST => {} // const is ok!
    other_values => {}
}
Run

Back to list of error codes