]> git.lizzy.rs Git - rust.git/blob - tests/ui/match/issue-56685.rs
Rollup merge of #107074 - lcnr:validate-dont-skip-opaque, r=compiler-errors
[rust.git] / tests / ui / match / issue-56685.rs
1 #![allow(dead_code)]
2 #![deny(unused_variables)]
3
4 // This test aims to check that unused variable suggestions update bindings in all
5 // match arms.
6
7 fn main() {
8     enum E {
9         A(i32,),
10         B(i32,),
11     }
12
13     match E::A(1) {
14         E::A(x) | E::B(x) => {}
15         //~^ ERROR unused variable: `x`
16     }
17
18     enum F {
19         A(i32, i32,),
20         B(i32, i32,),
21         C(i32, i32,),
22     }
23
24     let _ = match F::A(1, 2) {
25         F::A(x, y) | F::B(x, y) => { y },
26         //~^ ERROR unused variable: `x`
27         F::C(a, b) => { 3 }
28         //~^ ERROR unused variable: `a`
29         //~^^ ERROR unused variable: `b`
30     };
31
32     let _ = if let F::A(x, y) | F::B(x, y) = F::A(1, 2) {
33     //~^ ERROR unused variable: `x`
34         y
35     } else {
36         3
37     };
38
39     while let F::A(x, y) | F::B(x, y) = F::A(1, 2) {
40     //~^ ERROR unused variable: `x`
41         let _ = y;
42         break;
43     }
44 }