Open
Description
Code
fn main() {
struct Foo { x: i32, ch: char }
let pos = Foo { x: 2, ch: 'x' };
match pos {
Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' } => (),
_ => todo!(),
}
}
Current output
Compiling test_ v0.1.0 (/home/lrne/Project/Rust/test_)
error: unexpected `,` in pattern
--> src/main.rs:5:30
|
5 | Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' } => (),
| ^
|
help: try adding parentheses to match on a tuple...
|
5 | (Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' }) => (),
| + +
help: ...or a vertical bar to match on multiple alternatives
|
5 - Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' } => (),
5 + Foo { x: 2 | ch: ' |' } | Foo { x: 3 | ch: '@' } => (),
|
error: could not compile `test_` (bin "test_") due to 1 previous error
Desired output
Compiling test_ v0.1.0 (/home/lrne/Project/Rust/test_)
error: unexpected `,` in pattern
--> src/main.rs:5:30
|
5 | Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' } => (),
| ^
|
help: try adding parentheses to match on a tuple...
|
5 | (Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' }) => (),
| + +
help: ...or a vertical bar to match on multiple alternatives
|
5 - Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' } => (),
5 + Foo { x: 2, ch: ',' } | Foo { x: 3, ch: '@' } => (),
|
error: could not compile `test_` (bin "test_") due to 1 previous error
Rationale and extra context
No response
Other cases
Rust Version
rustc 1.88.0-nightly (a15cce269 2025-04-17)
binary: rustc
commit-hash: a15cce2690e8fab72422515c9dc02c6fbc506733
commit-date: 2025-04-17
host: aarch64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2
Anything else?
No response