]> git.lizzy.rs Git - rust.git/blob - tests/ui/shadow.rs
e366c75335c20357659021928b32b4e834206997
[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::manual_unwrap_or,
12     clippy::missing_docs_in_private_items,
13     clippy::single_match
14 )]
15
16 fn id<T>(x: T) -> T {
17     x
18 }
19
20 #[must_use]
21 fn first(x: (isize, isize)) -> isize {
22     x.0
23 }
24
25 fn main() {
26     let mut x = 1;
27     let x = &mut x;
28     let x = { x };
29     let x = (&*x);
30     let x = { *x + 1 };
31     let x = id(x);
32     let x = (1, x);
33     let x = first(x);
34     let y = 1;
35     let x = y;
36
37     let x;
38     x = 42;
39
40     let o = Some(1_u8);
41
42     if let Some(p) = o {
43         assert_eq!(1, p);
44     }
45     match o {
46         Some(p) => p, // no error, because the p above is in its own scope
47         None => 0,
48     };
49
50     match (x, o) {
51         (1, Some(a)) | (a, Some(1)) => (), // no error though `a` appears twice
52         _ => (),
53     }
54 }