about summary refs log tree commit diff
path: root/tests/ui/or-patterns/binding-typo.fixed
blob: f209ad644db975ab1a6d5d28ce3b4760305ea4c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Issue #51976
//@ run-rustfix
#![allow(unused_variables)] // allowed so we don't get overlapping suggestions
enum Lol {
    Foo,
    Bar,
}

fn foo(x: (Lol, Lol)) {
    use Lol::*;
    match &x {
        (Foo, Bar) | (Bar, Foo) => {}
        //~^ ERROR: variable `Ban` is not bound in all patterns
        //~| HELP: you might have meant to use the similarly named previously used binding `Bar`
        //~| NOTE: pattern doesn't bind `Ban`
        //~| NOTE: variable not in all patterns
        _ => {}
    }
    match &x {
        (Foo, _) | (Bar, Foo) => {}
        //~^ ERROR: variable `Ban` is not bound in all patterns
        //~| HELP: you might have meant to use the similarly named unit variant `Bar`
        //~| NOTE: pattern doesn't bind `Ban`
        //~| NOTE: variable not in all patterns
        _ => {}
    }
}

fn main() {
    use Lol::*;
    foo((Foo, Bar));
}