Rust
E0532 Expected Tuple Variant Fix
A tuple variant carries data, so its pattern must say what happens to that data. Writing the variant name bare, with no parentheses, is E0532. Add the parentheses - bind the payload, or ignore it with an underscore - and the same pattern compiles.
Written November 28, 2026 · Tested with Rust 1.99.1 · 10 min read
- The rule underneath: a pattern mirrors the declaration
- The first failure: a tuple variant named bare in an if let
- The second failure: the same bare name in a match arm
- The fix: add the parentheses, bind or ignore the payload
Written November 28, 2026
Tested with Rust 1.99.1
What this guide is
Error E0532 is a pattern written for the wrong kind of variant. The error codes index sums it up in one line: pattern arm did not match expected kind. A bare path in a pattern - a name with nothing after it - is a pattern for a unit struct, a unit variant, or a constant: things that carry no data. When that name resolves to a tuple variant, a variant declared with fields in parentheses, the pattern has left the variant's data unaccounted for, and the compiler refuses it. The fix the index gives is to make the match arm's kind the same as the value matched: give the pattern the same parentheses the declaration has, with a binding or an underscore for each field.
This guide reproduces E0532 twice, in an if let and in a match, with the same small enum. It then gives the fix in both useful forms: ignore the payload, or bind it and use it. The last sections separate the cases that look similar but are different errors - a tuple struct named the same bare way, and a tuple pattern with the wrong number of fields - and show the pattern forms the unit and struct variants of the same enum use, which are not errors at all.
The rule underneath: a pattern mirrors the declaration
The Rust Reference's patterns chapter divides patterns by the shape they match. Path patterns refer to constants, structs, or enum variants that have no fields. Tuple struct patterns - the name followed by subpatterns in parentheses - match tuple structs and tuple-like enum variants, and destructure them. So the kind of pattern is chosen by the declaration, not by what the code wants to do with the value: a variant declared as Circle(u32) is matched by a tuple struct pattern, and writing it as a path pattern claims it has no fields. That claim is what E0532 reports, in the header's own words: expected unit struct, unit variant or constant, found tuple variant.
The first failure: a tuple variant named bare in an if let
enum Shape {
Circle(u32),
Square,
}
fn main() {
let shape = Shape::Circle(5);
if let Shape::Circle = shape {
println!("circle");
}
}
$ rustc --edition 2021 p1_fail_iflet.rs -o p1_fail_iflet.bin
error[E0532]: expected unit struct, unit variant or constant, found tuple variant `Shape::Circle`
--> p1_fail_iflet.rs:8:12
|
2 | Circle(u32),
| ----------- `Shape::Circle` defined here
...
8 | if let Shape::Circle = shape {
| ^^^^^^^^^^^^^ help: use the tuple variant pattern syntax instead: `Shape::Circle(_)`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0532`.
The diagnostic points both ways: a note on the declaration line, Circle(u32), and the caret under the whole pattern. The help attached to the caret is the fix in its shortest form - use the tuple variant pattern syntax instead, Shape::Circle(_). Nothing else in the program is wrong: the value, the variant, and the if let are all fine. Only the pattern's shape disagrees with the declaration.
The second failure: the same bare name in a match arm
enum Shape {
Circle(u32),
Square,
}
fn main() {
let shape = Shape::Circle(5);
match shape {
Shape::Circle => println!("circle"),
Shape::Square => println!("square"),
}
}
$ rustc --edition 2021 p2_fail_match.rs -o p2_fail_match.bin
error[E0532]: expected unit struct, unit variant or constant, found tuple variant `Shape::Circle`
--> p2_fail_match.rs:9:9
|
2 | Circle(u32),
| ----------- `Shape::Circle` defined here
...
9 | Shape::Circle => println!("circle"),
| ^^^^^^^^^^^^^ help: use the tuple variant pattern syntax instead: `Shape::Circle(_)`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0532`.
The error is identical, because the pattern is identical - the place it sits, an if let or a match arm, does not change which kind of pattern it is. Note the other arm: Shape::Square is a unit variant, declared with no fields, so its bare path pattern is correct and draws no error. The two arms of one match show the rule directly: the pattern form follows each variant's own declaration.
The fix: add the parentheses, bind or ignore the payload
A tuple variant pattern has one subpattern per field. Bind a field to use its value, or write _ for a field the code does not need:
enum Shape {
Circle(u32),
Square,
}
fn describe(shape: Shape) {
if let Shape::Circle(radius) = shape {
println!("circle radius {}", radius);
}
if let Shape::Square = shape {
println!("square");
}
}
fn main() {
describe(Shape::Circle(5));
let other = Shape::Circle(9);
if let Shape::Circle(_) = other {
println!("circle, payload ignored");
}
describe(Shape::Square);
}
$ rustc --edition 2021 p3_fix.rs -o p3_fix.bin
$ ./p3_fix.bin
circle radius 5
circle, payload ignored
square
The bound form puts the payload in hand: radius is the u32 the variant carried, and the first line of output prints it. The underscore form is the one the compiler's help suggests: it matches any Circle value and discards the payload, which is the right pattern when only the variant matters. Both forms have the parentheses; that is the whole change from the failing programs. For a variant with several fields, write one subpattern per field, in declaration order.
Neighboring error: a tuple struct named bare is E0530, not E0532
A tuple struct invites the same mistake - naming it with no parentheses - but the compiler reports a different error. A single-segment name in a pattern can also be read as a new binding, and a binding may not take a tuple struct's name:
struct Point(i32, i32);
fn main() {
let p = Point(3, 4);
match p {
Point => println!("point"),
_ => println!("other"),
}
}
$ rustc --edition 2021 p4_tuple_struct_match.rs -o p4_tuple_struct_match.bin
error[E0530]: match bindings cannot shadow tuple structs
--> p4_tuple_struct_match.rs:6:9
|
1 | struct Point(i32, i32);
| ----------------------- the tuple struct `Point` is defined here
...
6 | Point => println!("point"),
| ^^^^^
| |
| cannot be named the same as a tuple struct
| help: try specify the pattern arguments: `Point(..)`
warning: unreachable pattern
--> p4_tuple_struct_match.rs:7:9
|
6 | Point => println!("point"),
| ----- matches any value
7 | _ => println!("other"),
| ^ no value can reach this
|
= note: `#[warn(unreachable_patterns)]` (part of `#[warn(unused)]`) on by default
warning: unused variable: `Point`
--> p4_tuple_struct_match.rs:6:9
|
6 | Point => println!("point"),
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_Point`
|
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
error: aborting due to 1 previous error; 2 warnings emitted
For more information about this error, try `rustc --explain E0530`.
The two warnings in that output follow from the same misreading: taken as a binding, Point would match every value, so the _ arm is unreachable and the binding itself is unused. The header and the help still lead to the same repair - specify the pattern arguments. The fix for a tuple struct is the same shape as the fix for a tuple variant:
struct Point(i32, i32);
fn main() {
let p = Point(3, 4);
let Point(x, y) = p;
println!("point {} {}", x, y);
}
$ rustc --edition 2021 p5_fix_struct.rs -o p5_fix_struct.bin
$ ./p5_fix_struct.bin
point 3 4
Both fields are bound and printed. Writing Point(..) instead, as the E0530 help suggests, matches the value and ignores every field. Read the header before choosing a repair path: E0532 and E0530 end at the same pattern syntax, but they are different reports about different declarations - a tuple variant in the first case, a tuple struct in the second.
The forms that were never errors: unit and struct variants
Each variant kind has its own pattern form, and the other two forms in the same enum compile as written. A unit variant takes the bare path. A struct variant takes braces with its field names:
enum Shape {
Circle(u32),
Square,
Rect { width: u32, height: u32 },
}
fn main() {
let a = Shape::Square;
if let Shape::Square = a {
println!("square");
}
let b = Shape::Rect { width: 2, height: 3 };
if let Shape::Rect { width, height } = b {
println!("rect {}x{}", width, height);
}
let c = Shape::Circle(7);
if let Shape::Circle(r) = c {
println!("circle {}", r);
}
}
$ rustc --edition 2021 p6_neighbours_ok.rs -o p6_neighbours_ok.bin
$ ./p6_neighbours_ok.bin
square
rect 2x3
circle 7
Three variants, three pattern forms, one per declaration: no parentheses for Square, braces and field names for Rect, parentheses for Circle. If a pattern draws E0532, the form does not match the declaration it names - checking the declaration is the fastest way to see which form is owed.
Neighboring error: the wrong number of fields is E0023
Adding parentheses is not enough on its own: the pattern must also account for the right number of fields. Two subpatterns for a one-field variant is a different error:
enum Shape {
Circle(u32),
Square,
}
fn main() {
let shape = Shape::Circle(5);
if let Shape::Circle(a, b) = shape {
println!("{} {}", a, b);
}
}
$ rustc --edition 2021 p7_wrong_count.rs -o p7_wrong_count.bin
error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has 1 field
--> p7_wrong_count.rs:8:26
|
2 | Circle(u32),
| --- tuple variant has 1 field
...
8 | if let Shape::Circle(a, b) = shape {
| ^ ^ expected 1 field, found 2
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0023`.
The carets sit on the two subpatterns, not on the variant name: the kind is right now, the count is wrong. Match the count to the declaration - one subpattern per field - and use _ for any field the code does not need, rather than dropping the subpattern.
Decision summary
- The header says "expected unit struct, unit variant or constant, found tuple variant" (E0532): a tuple variant was named with no parentheses - rewrite the pattern with the tuple variant syntax, one subpattern per field.
- The payload is needed: bind it, as in
Shape::Circle(radius), and use the binding in the arm or block. - The payload is not needed: write
Shape::Circle(_)- the exact form the compiler's help suggests - or one_per field for a wider variant. - The header instead says "match bindings cannot shadow tuple structs" (E0530): the bare name is a tuple struct, not a variant - the repair is the same parentheses, as in
Point(x, y)orPoint(..). - The header instead says "this pattern has 2 fields, but the corresponding tuple variant has 1 field" (E0023), with the count adjusted to your variant: the parentheses are present but the subpattern count is wrong - match it to the declaration.
Checklist
- Every tuple variant pattern has parentheses, with one subpattern per declared field.
- Each field is bound under a name the code uses, or written as
_on purpose. - Unit variants are still written bare, and struct variants still use braces with field names.
- No bare tuple struct name stands as a pattern - it takes
Point(x, y),Point(..), or the field form the code needs. - The fixed program compiles, runs, and its output shows the bound payload values where the code prints them.
Related guides
- E0004 Non-Exhaustive Patterns Fix - the other pattern-shape error a
matchdraws: the patterns are well-formed, but together they leave a value of the type uncovered. - E0510 Cannot Assign in Match Guard Fix - a restriction on the other side of a
matcharm: what a guard may do while the pattern is still being decided.
Sources
- Rust, Error codes index: E0532 - the definition of the error: a pattern arm did not match the expected kind; its example fails on a tuple variant named with no parentheses, and its stated fix is to make the match arm's kind the same as the expression matched, binding the payload in the corrected example.
- The Rust Reference, Patterns - the pattern kinds and what each matches: path patterns refer to constants, structs, or enum variants that have no fields, while tuple struct patterns match tuple structs and tuple-like enum variants and are used to destructure them.
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.