1 #![warn(clippy::shadow_same, clippy::shadow_reuse, clippy::shadow_unrelated)]
2
shadow_same()3 fn shadow_same() {
4 let x = 1;
5 let x = x;
6 let mut x = &x;
7 let x = &mut x;
8 let x = *x;
9 }
10
shadow_reuse() -> Option<()>11 fn shadow_reuse() -> Option<()> {
12 let x = ([[0]], ());
13 let x = x.0;
14 let x = x[0];
15 let [x] = x;
16 let x = Some(x);
17 let x = foo(x);
18 let x = || x;
19 let x = Some(1).map(|_| x)?;
20 let y = 1;
21 let y = match y {
22 1 => 2,
23 _ => 3,
24 };
25 None
26 }
27
shadow_unrelated()28 fn shadow_unrelated() {
29 let x = 1;
30 let x = 2;
31 }
32
syntax()33 fn syntax() {
34 fn f(x: u32) {
35 let x = 1;
36 }
37 let x = 1;
38 match Some(1) {
39 Some(1) => {},
40 Some(x) => {
41 let x = 1;
42 },
43 _ => {},
44 }
45 if let Some(x) = Some(1) {}
46 while let Some(x) = Some(1) {}
47 let _ = |[x]: [u32; 1]| {
48 let x = 1;
49 };
50 }
51
negative()52 fn negative() {
53 match Some(1) {
54 Some(x) if x == 1 => {},
55 Some(x) => {},
56 None => {},
57 }
58 match [None, Some(1)] {
59 [Some(x), None] | [None, Some(x)] => {},
60 _ => {},
61 }
62 if let Some(x) = Some(1) {
63 let y = 1;
64 } else {
65 let x = 1;
66 let y = 1;
67 }
68 let x = 1;
69 #[allow(clippy::shadow_unrelated)]
70 let x = 1;
71 }
72
foo<T>(_: T)73 fn foo<T>(_: T) {}
74
question_mark() -> Option<()>75 fn question_mark() -> Option<()> {
76 let val = 1;
77 // `?` expands with a `val` binding
78 None?;
79 None
80 }
81
main()82 fn main() {}
83