]> git.lizzy.rs Git - rust.git/blob - tests/ui/shadow.rs
arm.pats -> arm.pat
[rust.git] / tests / ui / shadow.rs
1 #![warn(
2     clippy::all,
3     clippy::pedantic,
4     clippy::shadow_same,
5     clippy::shadow_reuse,
6     clippy::shadow_unrelated
7 )]
8 #![allow(
9     unused_parens,
10     unused_variables,
11     clippy::missing_docs_in_private_items,
12     clippy::single_match
13 )]
14
15 fn id<T>(x: T) -> T {
16     x
17 }
18
19 fn first(x: (isize, isize)) -> isize {
20     x.0
21 }
22
23 fn main() {
24     let mut x = 1;
25     let x = &mut x;
26     let x = { x };
27     let x = (&*x);
28     let x = { *x + 1 };
29     let x = id(x);
30     let x = (1, x);
31     let x = first(x);
32     let y = 1;
33     let x = y;
34
35     let x;
36     x = 42;
37
38     let o = Some(1_u8);
39
40     if let Some(p) = o {
41         assert_eq!(1, p);
42     }
43     match o {
44         Some(p) => p, // no error, because the p above is in its own scope
45         None => 0,
46     };
47
48     match (x, o) {
49         (1, Some(a)) | (a, Some(1)) => (), // no error though `a` appears twice
50         _ => (),
51     }
52 }