File tree Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Original file line number Diff line number Diff line change 1+ // Issue #51976
2+ //@ run-rustfix
3+ #![deny(unused_variables)] //~ NOTE: the lint level is defined here
4+ enum Lol {
5+ Foo,
6+ Bar,
7+ }
8+
9+ fn foo(x: (Lol, Lol)) {
10+ use Lol::*;
11+ match x {
12+ (Foo, Bar) | (Bar, Foo) => {}
13+ //~^ ERROR: variable `Ban` is not bound in all patterns
14+ //~| HELP: you might have meant to use the similarly named previously used binding `Bar`
15+ //~| NOTE: pattern doesn't bind `Ban`
16+ //~| NOTE: variable not in all patterns
17+ //~| ERROR: variable `Ban` is assigned to, but never used
18+ //~| NOTE: consider using `_Ban` instead
19+ _ => {}
20+ }
21+ }
22+
23+ fn main() {
24+ use Lol::*;
25+ foo((Foo, Bar));
26+ }
Original file line number Diff line number Diff line change 1+ // Issue #51976
2+ //@ run-rustfix
3+ #![ deny( unused_variables) ] //~ NOTE: the lint level is defined here
4+ enum Lol {
5+ Foo ,
6+ Bar ,
7+ }
8+
9+ fn foo ( x : ( Lol , Lol ) ) {
10+ use Lol :: * ;
11+ match x {
12+ ( Foo , Bar ) | ( Ban , Foo ) => { }
13+ //~^ ERROR: variable `Ban` is not bound in all patterns
14+ //~| HELP: you might have meant to use the similarly named previously used binding `Bar`
15+ //~| NOTE: pattern doesn't bind `Ban`
16+ //~| NOTE: variable not in all patterns
17+ //~| ERROR: variable `Ban` is assigned to, but never used
18+ //~| NOTE: consider using `_Ban` instead
19+ _ => { }
20+ }
21+ }
22+
23+ fn main ( ) {
24+ use Lol :: * ;
25+ foo ( ( Foo , Bar ) ) ;
26+ }
Original file line number Diff line number Diff line change 1+ error[E0408]: variable `Ban` is not bound in all patterns
2+ --> $DIR/binding-typo.rs:12:9
3+ |
4+ LL | (Foo, Bar) | (Ban, Foo) => {}
5+ | ^^^^^^^^^^ --- variable not in all patterns
6+ | |
7+ | pattern doesn't bind `Ban`
8+ |
9+ help: you might have meant to use the similarly named previously used binding `Bar`
10+ |
11+ LL - (Foo, Bar) | (Ban, Foo) => {}
12+ LL + (Foo, Bar) | (Bar, Foo) => {}
13+ |
14+
15+ error: variable `Ban` is assigned to, but never used
16+ --> $DIR/binding-typo.rs:12:23
17+ |
18+ LL | (Foo, Bar) | (Ban, Foo) => {}
19+ | ^^^
20+ |
21+ = note: consider using `_Ban` instead
22+ note: the lint level is defined here
23+ --> $DIR/binding-typo.rs:3:9
24+ |
25+ LL | #![deny(unused_variables)]
26+ | ^^^^^^^^^^^^^^^^
27+
28+ error: aborting due to 2 previous errors
29+
30+ For more information about this error, try `rustc --explain E0408`.
You can’t perform that action at this time.
0 commit comments