]> git.lizzy.rs Git - rust.git/blob - tests/ui/match_single_binding.fixed
Auto merge of #4809 - iankronquist:patch-1, r=flip1995
[rust.git] / tests / ui / match_single_binding.fixed
1 // run-rustfix
2
3 #![warn(clippy::match_single_binding)]
4 #![allow(clippy::many_single_char_names, clippy::toplevel_ref_arg)]
5
6 struct Point {
7     x: i32,
8     y: i32,
9 }
10
11 fn main() {
12     let a = 1;
13     let b = 2;
14     let c = 3;
15     // Lint
16     let (x, y, z) = (a, b, c);
17     {
18         println!("{} {} {}", x, y, z);
19     }
20     // Lint
21     let (x, y, z) = (a, b, c);
22     println!("{} {} {}", x, y, z);
23     // Ok
24     match a {
25         2 => println!("2"),
26         _ => println!("Not 2"),
27     }
28     // Ok
29     let d = Some(5);
30     match d {
31         Some(d) => println!("{}", d),
32         _ => println!("None"),
33     }
34     // Lint
35     println!("whatever");
36     // Lint
37     {
38         let x = 29;
39         println!("x has a value of {}", x);
40     }
41     // Lint
42     {
43         let e = 5 * a;
44         if e >= 5 {
45             println!("e is superior to 5");
46         }
47     }
48     // Lint
49     let p = Point { x: 0, y: 7 };
50     let Point { x, y } = p;
51     println!("Coords: ({}, {})", x, y);
52     // Lint
53     let Point { x: x1, y: y1 } = p;
54     println!("Coords: ({}, {})", x1, y1);
55     // Lint
56     let x = 5;
57     let ref r = x;
58     println!("Got a reference to {}", r);
59     // Lint
60     let mut x = 5;
61     let ref mut mr = x;
62     println!("Got a mutable reference to {}", mr);
63 }