forked from rust-lang/rust-clippy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshadow.rs
53 lines (46 loc) · 898 Bytes
/
shadow.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#![warn(
clippy::all,
clippy::pedantic,
clippy::shadow_same,
clippy::shadow_reuse,
clippy::shadow_unrelated
)]
#![allow(
unused_parens,
unused_variables,
clippy::missing_docs_in_private_items,
clippy::single_match
)]
fn id<T>(x: T) -> T {
x
}
#[must_use]
fn first(x: (isize, isize)) -> isize {
x.0
}
fn main() {
let mut x = 1;
let x = &mut x;
let x = { x };
let x = (&*x);
let x = { *x + 1 };
let x = id(x);
let x = (1, x);
let x = first(x);
let y = 1;
let x = y;
let x;
x = 42;
let o = Some(1_u8);
if let Some(p) = o {
assert_eq!(1, p);
}
match o {
Some(p) => p, // no error, because the p above is in its own scope
None => 0,
};
match (x, o) {
(1, Some(a)) | (a, Some(1)) => (), // no error though `a` appears twice
_ => (),
}
}