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