about summary refs log tree commit diff
path: root/tests/ui/suggestions/only-replace-intended-coma-not-all-in-pattern.fixed
blob: 0258f868f007261c17021378116b0ace3d909832 (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 coma with a bar, not all commas 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!(),
    }
}