Rust
E0408 Variable Not Bound in All Patterns Fix
An or-pattern offers the compiler two or more ways to match, but the arm body that follows gets only one set of variables - so every alternative has to bind the same names. E0408 is the compiler pointing at the alternative that leaves a name out. This guide separates the shapes that produce it and matches each one to its repair: split the arm, bind the name in every alternative, or give the case that has nothing to bind a value of its own.
Written November 29, 2026 · Tested with Rust 1.99.1 · 25 min read
- The rule underneath: every alternative binds the same variables, the same way
- How to read the diagnostic
- The first failure: a tuple variant matched against the variant with no value
- The second failure: a binding alternative next to a literal
Written November 29, 2026
Tested with Rust 1.99.1
What this guide is
Error E0408 is an or-pattern whose alternatives disagree about which variables they bind. The error codes index defines it in one sentence: an "or" pattern was used where the variable bindings are not consistently bound across patterns. Its own example is the first failure below - Some(y) | None - and its reasoning is the whole guide in miniature: y is bound to the contents of the Some, so the arm body may use it, but when the value is None nothing has specified what y is, and the body would use a variable that does not exist on that path. The index gives the two repairs this guide uses throughout: split the or-pattern into multiple match arms, or bind the variable in all sub-patterns of the or-pattern.
The forms in this guide each reproduce E0408 with a small, complete program, and each leaves the binding out in a different place. A tuple variant matched against the variant that carries no value. A binding alternative standing next to a literal. A struct variant matched against a unit variant, which has no field the binding could come from. The same defect one level down, in an or-pattern nested inside a tuple pattern. A binding alternative next to a wildcard alternative that matches the same variant and throws the value away. And the two places outside match where a parenthesized or-pattern can appear: a let pattern and a function parameter.
Several neighboring results are not E0408 and are worked only in the traps and the decision summary. A variable bound in every alternative but with a different type in each is E0308, not E0409. A variable bound in every alternative but with different mutability is E0409. A match that simply leaves a case out is E0004. And an or-pattern that binds the same variable in every alternative, or binds nothing in any of them, compiles - both are shown running in the traps.
Build every program in this guide with rustc --edition 2021. In the compiler transcripts below, the file names are the bare names shown on the command line.
The rule underneath: every alternative binds the same variables, the same way
An or-pattern - A | B | C - matches when any one of its alternatives matches, and the code after the => runs without knowing which one it was. That is why the alternatives cannot each bring their own variables: the body has one scope, so it can only use names that every path into it provides. The Rust Reference's patterns chapter states the constraint exactly: a pattern p | q is ill-formed if the same set of bindings is not introduced in p and in q, if the type inferred for p does not unify with the type inferred for q, or if the type or binding mode of any two bindings with the same name do not unify. Those three clauses are the three different errors in this area: a missing binding is E0408, a type that does not unify is E0308, and a binding mode that does not unify - mut y in one alternative, plain y in the other - is E0409. The traps work the second and third.
The same chapter draws the boundary for where a top-level or-pattern may appear at all: or-patterns are allowed anywhere other patterns are allowed, with the exceptions of let bindings and function and closure parameters. That is why the sixth and seventh failures below wrap the or-pattern in parentheses - (Some(y) | None) - which puts the or-pattern one level down, inside a tuple pattern, where it is allowed and where E0408 applies to it in full. Unparenthesized, the or-pattern is not available in those two positions at all.
The fix follows from the rule rather than from the header's wording. Since the defect is a name that exists on only some paths into one body, the repair is to make the set of names the same on every path: split the arm so each alternative has its own body and its own names (the right repair when the cases genuinely do different things, and the only repair when one alternative has nothing the name could bind), bind the name in every alternative (the right repair when every alternative really does carry a value for it, as in the index's (0, y) | (y, 0)), or stop using the pattern to produce the value at all and compute it with a match that returns a value from each arm (the right repair for let and for parameters). What never works is giving the body a fallback for the missing case inside the same arm - there is no syntax for "if this alternative matched" - or replacing the missing binding with _, which is the fifth failure: a wildcard binds nothing, so the disagreement is unchanged.
How to read the diagnostic
The header names the variable and states the defect in full: "variable y is not bound in all patterns". Below it, two spans locate the disagreement. A short span, underlined with a single dash, marks the binding itself - labeled "variable not in all patterns". A caret span marks the alternative that does not bind it - labeled "pattern doesn't bind y". Reading the two together gives the repair directly: either the caret-marked alternative gains a binding of the same name, or the arm splits so that alternative never reaches this body.
One more error usually travels with E0408, and it is not a second defect. When the arm body actually uses the unbound-in-one-alternative variable, the compiler also reports E0381, "used binding y is possibly-uninitialized", pointing at the use. It is the same fact seen from the body's side: on the path where the other alternative matched, the variable was never given a value. Fix the E0408 - split the arm or bind in every alternative - and the E0381 goes with it. If the body never uses the variable, E0408 appears on its own.
That pairing is also the fastest way to tell this error from its neighbors. When every alternative binds the name but the bindings disagree on type, the header is E0308 with the note "in the same arm, a binding must have the same type in all alternatives". When they disagree on mutability, the header is E0409, "bound inconsistently across alternatives separated by |". And when no or-pattern is involved at all and a case is simply missing, the header is E0004, non-exhaustive patterns. The traps work each of those.
The first failure: a tuple variant matched against the variant with no value
This is the error index's own example shape, and the most common way to meet E0408. Some(y) binds the payload; None has no payload, so there is nothing in that alternative for y to bind. The body then uses y, which also draws the companion E0381:
fn main() {
let x: Option<i32> = Some(7);
match x {
Some(y) | None => println!("value is {y}"),
_ => println!("unreachable"),
}
}
error[E0408]: variable `y` is not bound in all patterns
--> a1.rs:4:19
|
4 | Some(y) | None => println!("value is {y}"),
| - ^^^^ pattern doesn't bind `y`
| |
| variable not in all patterns
warning: unreachable pattern
--> a1.rs:5:9
|
4 | Some(y) | None => println!("value is {y}"),
| -------------- matches all the relevant values
5 | _ => println!("unreachable"),
| ^ no value can reach this
|
= note: `#[warn(unreachable_patterns)]` (part of `#[warn(unused)]`) on by default
error[E0381]: used binding `y` is possibly-uninitialized
--> a1.rs:4:47
|
4 | Some(y) | None => println!("value is {y}"),
| - ^ `y` used here but it is possibly-uninitialized
| |
| binding initialized here in some conditions
| binding declared here but left uninitialized
error: aborting due to 2 previous errors; 1 warning emitted
Some errors have detailed explanations: E0381, E0408.
For more information about an error, try `rustc --explain E0381`.
The warning is part of the same story: between them, Some and None already cover every value, so the _ arm can never run. There is no value in the None case for y to take, so binding it in every alternative is not available here - the arm has to split, giving None a body of its own that does not mention y:
fn main() {
let x: Option<i32> = Some(7);
match x {
Some(y) => println!("value is {y}"),
None => println!("no value"),
}
let z: Option<i32> = None;
match z {
Some(y) => println!("value is {y}"),
None => println!("no value"),
}
}
value is 7
no value
The output is value is 7, then no value: each case reaches the body written for it, and the None body never touches a variable it does not have.
The second failure: a binding alternative next to a literal
A literal pattern binds nothing, so standing one next to a binding alternative produces the same disagreement - here in its starkest form, where the binding alternative y on its own would match every i32 and the literal 0 adds nothing but the defect:
fn main() {
let n: i32 = 0;
match n {
y | 0 => println!("value is {y}"),
_ => println!("other"),
}
}
error[E0408]: variable `y` is not bound in all patterns
--> a2.rs:4:13
|
4 | y | 0 => println!("value is {y}"),
| - ^ pattern doesn't bind `y`
| |
| variable not in all patterns
warning: unreachable pattern
--> a2.rs:4:13
|
4 | y | 0 => println!("value is {y}"),
| - ^ no value can reach this
| |
| matches any value
|
= note: `#[warn(unreachable_patterns)]` (part of `#[warn(unused)]`) on by default
warning: unreachable pattern
--> a2.rs:5:9
|
4 | y | 0 => println!("value is {y}"),
| ----- matches all the relevant values
5 | _ => println!("other"),
| ^ no value can reach this
error[E0381]: used binding `y` is possibly-uninitialized
--> a2.rs:4:38
|
4 | y | 0 => println!("value is {y}"),
| - ^ `y` used here but it is possibly-uninitialized
| |
| binding initialized here in some conditions
| binding declared here but left uninitialized
error: aborting due to 2 previous errors; 2 warnings emitted
Some errors have detailed explanations: E0381, E0408.
For more information about an error, try `rustc --explain E0381`.
The warnings expose what the pattern was probably trying to say: treat 0 specially, and everything else generally. That is two arms, not one - the literal first, because a binding pattern placed first would take every value and leave the literal unreachable:
fn main() {
let n: i32 = 0;
match n {
0 => println!("value is 0"),
y => println!("value is {y}"),
}
let m: i32 = 5;
match m {
0 => println!("value is 0"),
y => println!("value is {y}"),
}
}
value is 0
value is 5
The output is value is 0, then value is 5: the literal arm takes the special case, and the binding arm takes - and names - everything else.
The third failure: a struct variant matched against a unit variant
With struct variants the binding comes out of a named field, and the alternative that breaks the set is the variant that has no such field. Shape::Point has no fields at all, so r cannot be bound there:
enum Shape {
Circle { radius: i32 },
Point,
}
fn main() {
let s = Shape::Circle { radius: 3 };
match s {
Shape::Circle { radius: r } | Shape::Point => println!("radius is {r}"),
}
}
error[E0408]: variable `r` is not bound in all patterns
--> a3.rs:8:39
|
8 | Shape::Circle { radius: r } | Shape::Point => println!("radius is {r}"),
| - ^^^^^^^^^^^^ pattern doesn't bind `r`
| |
| variable not in all patterns
error[E0381]: used binding `r` is possibly-uninitialized
--> a3.rs:8:76
|
8 | Shape::Circle { radius: r } | Shape::Point => println!("radius is {r}"),
| - ^ `r` used here but it is possibly-uninitialized
| |
| binding initialized here in some conditions
| binding declared here but left uninitialized
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0381, E0408.
For more information about an error, try `rustc --explain E0381`.
Note what is absent: no non-exhaustive warning, because the two alternatives do cover the whole enum. Coverage was never the problem - the variable set is. The repair is the same split as the first failure, and for the same reason: the Point case has no radius to report, so it needs a body that reports something else:
enum Shape {
Circle { radius: i32 },
Point,
}
fn main() {
let s = Shape::Circle { radius: 3 };
match s {
Shape::Circle { radius: r } => println!("radius is {r}"),
Shape::Point => println!("just a point"),
}
let p = Shape::Point;
match p {
Shape::Circle { radius: r } => println!("radius is {r}"),
Shape::Point => println!("just a point"),
}
}
radius is 3
just a point
The output is radius is 3, then just a point: the field binding lives only in the arm whose variant has the field.
The fourth failure: the or-pattern nested inside a tuple pattern
Nesting does not dilute the rule. Here the or-pattern sits in the first position of a tuple pattern, and its alternatives still have to agree with each other - Some(y) binds, None does not - regardless of the _ standing next to them:
fn main() {
let pair: (Option<i32>, i32) = (Some(4), 9);
match pair {
(Some(y) | None, _) => println!("value is {y}"),
_ => println!("other"),
}
}
error[E0408]: variable `y` is not bound in all patterns
--> a4.rs:4:20
|
4 | (Some(y) | None, _) => println!("value is {y}"),
| - ^^^^ pattern doesn't bind `y`
| |
| variable not in all patterns
warning: unreachable pattern
--> a4.rs:5:9
|
4 | (Some(y) | None, _) => println!("value is {y}"),
| ------------------- matches all the relevant values
5 | _ => println!("other"),
| ^ no value can reach this
|
= note: `#[warn(unreachable_patterns)]` (part of `#[warn(unused)]`) on by default
error[E0381]: used binding `y` is possibly-uninitialized
--> a4.rs:4:52
|
4 | (Some(y) | None, _) => println!("value is {y}"),
| - ^ `y` used here but it is possibly-uninitialized
| |
| binding initialized here in some conditions
| binding declared here but left uninitialized
error: aborting due to 2 previous errors; 1 warning emitted
Some errors have detailed explanations: E0381, E0408.
For more information about an error, try `rustc --explain E0381`.
The caret span points inside the tuple, at the None - the diagnostic reads the nested or-pattern on its own terms. The split therefore also happens at that level: the tuple pattern is written out once per case of its first element, and the second element stays a wildcard in both:
fn main() {
let pair: (Option<i32>, i32) = (Some(4), 9);
match pair {
(Some(y), _) => println!("value is {y}"),
(None, _) => println!("no value"),
}
}
value is 4
The output is value is 4: the nested choice became two whole patterns, which is what an or-pattern is shorthand for everywhere it appears.
The fifth failure: a binding alternative next to a wildcard alternative
A tempting half-fix for the first failure is to keep one arm and throw the payload away in the second alternative instead of naming the other variant. It fails identically, because Some(_) binds nothing - and it fails worse, because the second alternative can now never run at all: Some(y) already matches everything Some(_) would:
fn main() {
let x: Option<i32> = Some(2);
match x {
Some(y) | Some(_) => println!("value is {y}"),
None => println!("no value"),
}
}
error[E0408]: variable `y` is not bound in all patterns
--> a5.rs:4:19
|
4 | Some(y) | Some(_) => println!("value is {y}"),
| - ^^^^^^^ pattern doesn't bind `y`
| |
| variable not in all patterns
warning: unreachable pattern
--> a5.rs:4:19
|
4 | Some(y) | Some(_) => println!("value is {y}"),
| ------- ^^^^^^^ no value can reach this
| |
| matches all the relevant values
|
= note: `#[warn(unreachable_patterns)]` (part of `#[warn(unused)]`) on by default
error[E0381]: used binding `y` is possibly-uninitialized
--> a5.rs:4:50
|
4 | Some(y) | Some(_) => println!("value is {y}"),
| - ^ `y` used here but it is possibly-uninitialized
| |
| binding initialized here in some conditions
| binding declared here but left uninitialized
error: aborting due to 2 previous errors; 1 warning emitted
Some errors have detailed explanations: E0381, E0408.
For more information about an error, try `rustc --explain E0381`.
A wildcard is the right tool only when no alternative binds - the traps show Some(_) | None compiling for exactly that reason. Here the second alternative contributed nothing, so the fix is to delete it and let the single binding pattern stand as the arm:
fn main() {
let x: Option<i32> = Some(2);
match x {
Some(y) => println!("value is {y}"),
None => println!("no value"),
}
}
value is 2
The output is value is 2: with the redundant alternative gone, the arm is one pattern with one binding, and there is no set to disagree.
The sixth failure: the or-pattern inside a let pattern
A top-level or-pattern is not allowed in a let at all, but a parenthesized one - the or-pattern nested in a tuple pattern - is, and it carries the full rule with it. The let also has to be able to fail or cover every case, and this one covers both variants of the Option, so the only complaint is the binding set:
fn main() {
let x: Option<i32> = Some(1);
let (Some(y) | None) = x;
println!("value is {y}");
}
error[E0408]: variable `y` is not bound in all patterns
--> a6_let.rs:3:20
|
3 | let (Some(y) | None) = x;
| - ^^^^ pattern doesn't bind `y`
| |
| variable not in all patterns
error[E0381]: used binding `y` is possibly-uninitialized
--> a6_let.rs:4:25
|
3 | let (Some(y) | None) = x;
| -
| |
| binding initialized here in some conditions
| binding declared here but left uninitialized
4 | println!("value is {y}");
| ^ `y` used here but it is possibly-uninitialized
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0381, E0408.
For more information about an error, try `rustc --explain E0381`.
There is no arm to split in a let, so the repair changes shape: produce the value with a match instead, where each case returns the value that case should mean. Here the None case takes the default 0, which is a decision the split makes visible instead of hiding inside a pattern:
fn main() {
let x: Option<i32> = Some(1);
let y = match x {
Some(y) => y,
None => 0,
};
println!("value is {y}");
let z: Option<i32> = None;
let w = match z {
Some(y) => y,
None => 0,
};
println!("value is {w}");
}
value is 1
value is 0
The output is value is 1, then value is 0: both cases produce a y, by construction - the second one by the explicit default the let pattern had no way to state.
The seventh failure: the or-pattern inside a function parameter
Parameters follow the same rule as let, for the same reason: a top-level or-pattern is not among the parameter patterns, but a parenthesized one is a tuple pattern, and the or-pattern inside it must bind consistently. The body of the function is the "arm body" here, and it uses y - so the companion E0381 points into the body:
fn show((Some(y) | None): Option<i32>) {
println!("value is {y}");
}
fn main() {
show(Some(8));
}
error[E0408]: variable `y` is not bound in all patterns
--> a7_param.rs:1:20
|
1 | fn show((Some(y) | None): Option<i32>) {
| - ^^^^ pattern doesn't bind `y`
| |
| variable not in all patterns
error[E0381]: used binding `y` is possibly-uninitialized
--> a7_param.rs:2:25
|
1 | fn show((Some(y) | None): Option<i32>) {
| -
| |
| binding initialized here in some conditions
| binding declared here but left uninitialized
2 | println!("value is {y}");
| ^ `y` used here but it is possibly-uninitialized
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0381, E0408.
For more information about an error, try `rustc --explain E0381`.
A parameter cannot be split either, so the destructuring moves into the body: take the whole value under one name, then match it where each case can be handled on its own:
fn show(x: Option<i32>) {
match x {
Some(y) => println!("value is {y}"),
None => println!("no value"),
}
}
fn main() {
show(Some(8));
show(None);
}
value is 8
no value
The output is value is 8, then no value: the caller passes both cases, and each is handled by the arm written for it.
The fixes in reach order
- Split the arm - one arm per alternative, each with its own body - when the alternatives genuinely do different things, and always when one alternative has nothing the variable could bind: a unit variant (
None,Shape::Point), a literal, or a wildcard. This is the first, third, and fifth failures' repair, and the error index's first prescription. - Bind the variable in every alternative when every alternative really does carry a value for it - the shape of
(0, y) | (y, 0), shown compiling in the traps. Check the types and the mutability as you do: a type mismatch turns the error into E0308 and amutmismatch into E0409. - When the pattern is a
letor a parameter and there is no arm to split, stop destructuring in the pattern: bind the whole value andmatchit in an expression or in the body, returning or handling each case explicitly - the sixth and seventh failures' repair. A default for the empty case, like the0above, is stated in thatmatch, where it belongs. - Delete a redundant alternative when one alternative already covers everything another would match - the fifth failure, where
Some(_)could never run next toSome(y).
Traps
y, so the binding set agrees; what does not agree is what y is - an i32 from the first position, a &str from the second. The compiler reports a plain type mismatch and adds the note that states the arm-level rule:fn main() {
let pair: (i32, &'static str) = (1, "a");
match pair {
(y, _) | (_, y) => println!("value is {y}"),
}
}
error[E0308]: mismatched types
--> n1_types.rs:4:22
|
3 | match pair {
| ---- this expression has type `(i32, &str)`
4 | (y, _) | (_, y) => println!("value is {y}"),
| - ^ expected `i32`, found `&str`
| |
| first introduced with type `i32` here
|
= note: in the same arm, a binding must have the same type in all alternatives
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
The repair is not a pattern repair: the two positions hold different kinds of value, so the cases need separate arms with separate bodies (or separate variable names, in separate arms), each using its own type.
Bound in every alternative, but with different mutability - E0409. Here both alternatives bind y with the same type, but the first binds it as mut y and the second as plain y. The binding modes do not unify, which is the Reference's third ill-formedness clause, and it has its own error code and its own header, "bound inconsistently across alternatives separated by |":
fn main() {
let pair: (i32, i32) = (0, 5);
match pair {
(mut y, 0) | (0, y) => println!("value is {y}"),
_ => println!("other"),
}
}
error[E0409]: variable `y` is bound inconsistently across alternatives separated by `|`
--> n2_mut.rs:4:26
|
4 | (mut y, 0) | (0, y) => println!("value is {y}"),
| - ^ bound in different ways
| |
| first binding
warning: variable does not need to be mutable
--> n2_mut.rs:4:10
|
4 | (mut y, 0) | (0, y) => println!("value is {y}"),
| ----^
| |
| help: remove this `mut`
|
= note: `#[warn(unused_mut)]` (part of `#[warn(unused)]`) on by default
error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0409`.
The repair is to make the binding mode the same in both alternatives - mut in both, if the body really reassigns the variable, or in neither.
A missing case with no or-pattern at all - E0004. The program below binds y in the only arm it has; its defect is not a disagreeing binding set but an uncovered variant, and the header says so:
fn main() {
let x: Option<i32> = Some(1);
match x {
Some(y) => println!("value is {y}"),
}
}
error[E0004]: non-exhaustive patterns: `None` not covered
--> n3_nonexhaustive.rs:3:11
|
3 | match x {
| ^ pattern `None` not covered
|
note: `Option<i32>` defined here
--> /home/droopy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:598:1
|
598 | pub enum Option<T> {
| ^^^^^^^^^^^^^^^^^^
...
602 | None,
| ---- not covered
= note: the matched value is of type `Option<i32>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
4 ~ Some(y) => println!("value is {y}"),
5 ~ None => todo!(),
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0004`.
The distinction matters because the repairs pull in opposite directions: E0408 is fixed by splitting one arm into two, E0004 by adding an arm that was never there. Note also the trap in the other direction - merging the None case into the Some(y) arm to "cover" it is exactly the first failure.
Bound in every alternative, same type, same way - compiles. This is the error index's second prescription working as intended: whichever position holds the 0, the other position supplies y, so y exists on every path into the body:
fn main() {
let pair: (i32, i32) = (0, 5);
match pair {
(0, y) | (y, 0) => println!("value is {y}"),
_ => println!("other"),
}
let pair2: (i32, i32) = (7, 0);
match pair2 {
(0, y) | (y, 0) => println!("value is {y}"),
_ => println!("other"),
}
}
value is 5
value is 7
The output is value is 5, then value is 7: the first pair binds y from its second position, the second pair from its first, and the single body serves both.
Bound in no alternative - compiles. The mirror image of the fifth failure: when every alternative is a wildcard or a literal, the binding set is empty in all of them, and empty sets agree:
fn main() {
let x: Option<i32> = Some(3);
match x {
Some(_) | None => println!("matched"),
}
}
matched
The output is matched. E0408 is never about wildcards as such - it is about one alternative binding a name another does not, and here neither does.
Decision summary
- The header is E0408 and one alternative binds a variable another does not: the defect is the binding set. Split the arm, bind the variable in every alternative, or - in a
letor a parameter - destructure in amatchinstead of in the pattern. - The caret span is the repair map: it marks the alternative that does not bind the named variable, and the dash span marks the binding. One of those two spans is what changes.
- An E0381 next to the E0408, pointing at the body's use of the same variable, is the same defect from the body's side - it disappears with the E0408 fix and needs no repair of its own.
- Neighbors ruled out by the header before applying this guide's repairs: E0308 for a binding whose type differs across alternatives, E0409 for a binding whose mutability differs, E0004 for a case missing with no or-pattern involved.
- Not errors at all: an or-pattern that binds the same variable, same type, same way in every alternative, and an or-pattern that binds nothing in any alternative. Both compile and run.
- After the repair, the program compiled and run, with the output showing each case reaching the body - or the value - written for it.
Checklist
- Read the two spans together: the dash span is the binding, the caret span is the alternative missing it.
- Ask of the caret-marked alternative: does it carry a value the variable could bind? If yes, bind it there. If no - unit variant, literal, wildcard - split the arm.
- If you bind in every alternative, confirm the type and the binding mode (
mut,ref) are the same in each. - In a
letor a parameter, remember the top-level or-pattern is not available there; the parenthesized form is a nested pattern and obeys the same rule. - If a default value for the empty case is what you actually want, state it in a
matchexpression - a pattern cannot state it. - Recheck the neighbors by header before repairing: E0308, E0409, and E0004 each take a different fix.
Related guides on this site
- E0409 Bound Inconsistently Across Patterns Fix
- Fix Rust E0277 "the trait bound ... is not satisfied" — Missing Trait Impl, Missing Ord, the ? Conversion, Sized, and Clone
- E0130 Patterns in Foreign Function Fix
- E0185 Method Has Self but Trait Does Not Fix
Sources
- Rust, Error codes index: E0408 - the definition of the error: an "or" pattern was used where the variable bindings are not consistently bound across patterns - with the
Some(y) | Noneexample, the explanation thatywould be nonexistent when the value isNone, and the two prescriptions this guide follows: split into multiple match arms, or bind the variable in all sub-patterns of the or-pattern, as in its(0, y) | (y, 0)example. - The Rust Reference, Patterns - the or-pattern rules this guide rests on: a pattern
p | qis ill-formed if the same set of bindings is not introduced in both, if the types do not unify, or if the types or binding modes of same-named bindings do not unify; and the syntactic boundary that or-patterns are allowed wherever patterns are allowed except at the top level ofletbindings and of function and closure parameters. - The Rust Programming Language, Patterns and Matching - the catalog of the places patterns occur - match arms,
letstatements, function parameters, and the rest - which is the map of positions the sixth and seventh failures are drawn from.
Keep Exploring
The full Rust hub \u2014 ownership, structs and enums, async, and measured comparisons.
Every guide on the site in one list, grouped by topic.
Every browser-only checker and verifier on the site.
The C++, Python, Sysadmin, Rust, Go, and TypeScript hubs.