]> git.lizzy.rs Git - rust.git/blob - tests/ui/non_expressive_names.rs
Auto merge of #3925 - phansch:3741, r=flip1995
[rust.git] / tests / ui / non_expressive_names.rs
1 #![warn(clippy::all)]
2 #![allow(unused, clippy::println_empty_string)]
3
4 #[derive(Clone, Debug)]
5 enum MaybeInst {
6     Split,
7     Split1(usize),
8     Split2(usize),
9 }
10
11 struct InstSplit {
12     uiae: usize,
13 }
14
15 impl MaybeInst {
16     fn fill(&mut self) {
17         let filled = match *self {
18             MaybeInst::Split1(goto1) => panic!(1),
19             MaybeInst::Split2(goto2) => panic!(2),
20             _ => unimplemented!(),
21         };
22         unimplemented!()
23     }
24 }
25
26 fn bla() {
27     let a: i32;
28     let (b, c, d): (i32, i64, i16);
29     {
30         {
31             let cdefg: i32;
32             let blar: i32;
33         }
34         {
35             let e: i32;
36         }
37         {
38             let e: i32;
39             let f: i32;
40         }
41         match 5 {
42             1 => println!(""),
43             e => panic!(),
44         }
45         match 5 {
46             1 => println!(""),
47             _ => panic!(),
48         }
49     }
50 }
51
52 fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {}
53
54 fn bindings2() {
55     let (a, b, c, d, e, f, g, h) = unimplemented!();
56 }
57
58 fn shadowing() {
59     let a = 0i32;
60     let a = 0i32;
61     let a = 0i32;
62     let a = 0i32;
63     let a = 0i32;
64     let a = 0i32;
65     {
66         let a = 0i32;
67     }
68 }
69
70 fn patterns() {
71     enum Z {
72         A(i32),
73         B(i32),
74         C(i32),
75         D(i32),
76         E(i32),
77         F(i32),
78     }
79
80     // These should not trigger a warning, since the pattern bindings are a new scope.
81     match Z::A(0) {
82         Z::A(a) => {},
83         Z::B(b) => {},
84         Z::C(c) => {},
85         Z::D(d) => {},
86         Z::E(e) => {},
87         Z::F(f) => {},
88     }
89 }
90
91 fn underscores_and_numbers() {
92     let _1 = 1; //~ERROR Consider a more descriptive name
93     let ____1 = 1; //~ERROR Consider a more descriptive name
94     let __1___2 = 12; //~ERROR Consider a more descriptive name
95     let _1_ok = 1;
96 }
97
98 fn issue2927() {
99     let args = 1;
100     format!("{:?}", 2);
101 }
102
103 fn issue3078() {
104     match "a" {
105         stringify!(a) => {},
106         _ => {},
107     }
108 }
109
110 struct Bar;
111
112 impl Bar {
113     fn bar() {
114         let _1 = 1;
115         let ____1 = 1;
116         let __1___2 = 12;
117         let _1_ok = 1;
118     }
119 }
120
121 fn main() {}