]> git.lizzy.rs Git - rust.git/blob - tests/ui/shadow.rs
Auto merge of #3603 - xfix:random-state-lint, r=phansch
[rust.git] / tests / ui / shadow.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 #![warn(
11     clippy::all,
12     clippy::pedantic,
13     clippy::shadow_same,
14     clippy::shadow_reuse,
15     clippy::shadow_unrelated
16 )]
17 #![allow(unused_parens, unused_variables, clippy::missing_docs_in_private_items)]
18
19 fn id<T>(x: T) -> T {
20     x
21 }
22
23 fn first(x: (isize, isize)) -> isize {
24     x.0
25 }
26
27 fn main() {
28     let mut x = 1;
29     let x = &mut x;
30     let x = { x };
31     let x = (&*x);
32     let x = { *x + 1 };
33     let x = id(x);
34     let x = (1, x);
35     let x = first(x);
36     let y = 1;
37     let x = y;
38
39     let x;
40     x = 42;
41
42     let o = Some(1_u8);
43
44     if let Some(p) = o {
45         assert_eq!(1, p);
46     }
47     match o {
48         Some(p) => p, // no error, because the p above is in its own scope
49         None => 0,
50     };
51
52     match (x, o) {
53         (1, Some(a)) | (a, Some(1)) => (), // no error though `a` appears twice
54         _ => (),
55     }
56 }