Why this fires¶
An enum pattern names a real variant but destructures it with the wrong payload shape. Unit, tuple, and struct variants have distinct pattern forms, and tuple arity and struct fields must agree with the declaration.
enum Event {
Done,
Pair(int, int),
Click { x: int, y: int },
}
match event {
Event::Done(value) => value, // TE830: `Done` is unit
Event::Pair(value) => value, // TE830: expected two elements
Event::Click(value) => value, // TE830: use `{ ... }`
}TE830 also reports unknown or duplicate named fields and omitted fields when
the pattern has no .. rest marker.
Fix it¶
Mirror the variant declaration in the pattern:
match event {
Event::Done => 0,
Event::Pair(left, right) => left + right,
Event::Click { x, y } => x + y,
}Use .. when intentionally ignoring named fields:
Event::Click { x, .. } => xNotes¶
- Tuple variants require exactly the declared number of subpatterns.
- Unit variants accept no tuple or struct payload.
- Struct variants reject unknown and duplicate field names.
- Omitting declared struct fields is allowed only with an explicit
... - An unknown variant name is reported separately as
TE133.