blob: 5bd267c3bc4023ccbe203d40a246a7e42265f8d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
//@ run-rustfix
// Regression test for issue #143330.
// Ensure we suggest to replace only the intended bar with a comma, not all bars in the pattern.
fn main() {
struct Foo { x: i32, ch: char }
let pos = Foo { x: 2, ch: 'x' };
match pos {
// All commas here were replaced with bars.
// Foo { x: 2 | ch: ' |' } | Foo { x: 3 | ch: '@' } => (),
Foo { x: 2, ch: ',' }, Foo { x: 3, ch: '@' } => (),
//~^ ERROR unexpected `,` in pattern
//~| HELP try adding parentheses to match on a tuple...
//~| HELP ...or a vertical bar to match on alternative
_ => todo!(),
}
}
|