]> git.lizzy.rs Git - rust.git/blob - tests/ui/non_expressive_names.rs
Merge pull request #2984 from flip1995/single_char_pattern
[rust.git] / tests / ui / non_expressive_names.rs
1
2
3 #![warn(clippy,similar_names)]
4 #![allow(unused)]
5
6
7 struct Foo {
8     apple: i32,
9     bpple: i32,
10 }
11
12 fn main() {
13     let specter: i32;
14     let spectre: i32;
15
16     let apple: i32;
17
18     let bpple: i32;
19
20     let cpple: i32;
21
22
23     let a_bar: i32;
24     let b_bar: i32;
25     let c_bar: i32;
26
27     let items = [5];
28     for item in &items {
29         loop {}
30     }
31
32     let foo_x: i32;
33     let foo_y: i32;
34
35     let rhs: i32;
36     let lhs: i32;
37
38     let bla_rhs: i32;
39     let bla_lhs: i32;
40
41     let blubrhs: i32;
42     let blublhs: i32;
43
44     let blubx: i32;
45     let bluby: i32;
46
47
48     let cake: i32;
49     let cakes: i32;
50     let coke: i32;
51
52     match 5 {
53         cheese @ 1 => {},
54         rabbit => panic!(),
55     }
56     let cheese: i32;
57     match (42, 43) {
58         (cheese1, 1) => {},
59         (cheese2, 2) => panic!(),
60         _ => println!(""),
61     }
62     let ipv4: i32;
63     let ipv6: i32;
64     let abcd1: i32;
65     let abdc2: i32;
66     let xyz1abc: i32;
67     let xyz2abc: i32;
68     let xyzeabc: i32;
69
70     let parser: i32;
71     let parsed: i32;
72     let parsee: i32;
73
74
75     let setter: i32;
76     let getter: i32;
77     let tx1: i32;
78     let rx1: i32;
79     let tx_cake: i32;
80     let rx_cake: i32;
81 }
82
83 fn foo() {
84     let Foo { apple, bpple } = unimplemented!();
85     let Foo { apple: spring,
86         bpple: sprang } = unimplemented!();
87 }
88
89 #[derive(Clone, Debug)]
90 enum MaybeInst {
91     Split,
92     Split1(usize),
93     Split2(usize),
94 }
95
96 struct InstSplit {
97     uiae: usize,
98 }
99
100 impl MaybeInst {
101     fn fill(&mut self) {
102         let filled = match *self {
103             MaybeInst::Split1(goto1) => panic!(1),
104             MaybeInst::Split2(goto2) => panic!(2),
105             _ => unimplemented!(),
106         };
107         unimplemented!()
108     }
109 }
110
111 fn bla() {
112     let a: i32;
113     let (b, c, d): (i32, i64, i16);
114     {
115         {
116             let cdefg: i32;
117             let blar: i32;
118         }
119         {
120             let e: i32;
121         }
122         {
123             let e: i32;
124             let f: i32;
125
126         }
127         match 5 {
128             1 => println!(""),
129             e => panic!(),
130         }
131         match 5 {
132             1 => println!(""),
133             _ => panic!(),
134         }
135     }
136 }
137
138 fn underscores_and_numbers() {
139     let _1 = 1; //~ERROR Consider a more descriptive name
140     let ____1 = 1; //~ERROR Consider a more descriptive name
141     let __1___2 = 12; //~ERROR Consider a more descriptive name
142     let _1_ok= 1;
143 }
144
145 struct Bar;
146
147 impl Bar {
148     fn bar() {
149         let _1 = 1;
150         let ____1 = 1;
151         let __1___2 = 12;
152         let _1_ok= 1;
153     }
154 }