Rust errors / Types and traits
Rust compiler error · checked with rustc 1.99.0
Rust error E0416: identifier `x` is bound more than once in the same pattern
What it meansAn identifier is bound more than once in a pattern.
What rustc prints
error[E0416]: identifier `x` is bound more than once in the same pattern
--> main.rs:4:9
|
4 | (x, x) => {} // error: identifier `x` is bound more than once in the
| ^ used in a pattern more than onceReal output of rustc 1.99.0 compiling the official example below (2021 edition). Your names and line numbers will differ; the first line is the part to match.
The compiler team's explanation
An identifier is bound more than once in a pattern.
Erroneous code example:
match (1, 2) {
(x, x) => {} // error: identifier `x` is bound more than once in the
// same pattern
}
Please verify you didn't misspell identifiers' name. Example:
match (1, 2) {
(x, y) => {} // ok!
}
Or maybe did you mean to unify? Consider using a guard:
match (A, B, C) {
(x, x2, see) if x == x2 => { /* A and B are equal, do one thing */ }
(y, z, see) => { /* A and B not equal; do another thing */ }
}From rustc --explain E0416 (1.99.0), part of the Rust project, MIT or Apache-2.0. Official page.
Related errors
- E0308mismatched types
- E0277the trait bound is not satisfied
- E0599no method named X found in the current scope
- E0433failed to resolve
- E0411cannot find type `Self` in this scope
- E0415identifier `f` is bound more than once in this parameter list
- E0422cannot find struct, variant or union type `Foo` in this scope
- E0428the name `Bar` is defined multiple times
Up next
Often hit nextE0308: mismatched typesA related error from the same family.Read it next →Did this answer your question?