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