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