]> git.lizzy.rs Git - rust.git/blob - tests/ui/reference.rs
Adapt the *.stderr files of the ui-tests to the tool_lints
[rust.git] / tests / ui / reference.rs
1 #![feature(tool_lints)]
2
3
4 fn get_number() -> usize {
5     10
6 }
7
8 fn get_reference(n : &usize) -> &usize {
9     n
10 }
11
12 #[allow(clippy::many_single_char_names, clippy::double_parens)]
13 #[allow(unused_variables)]
14 #[warn(clippy::deref_addrof)]
15 fn main() {
16     let a = 10;
17     let aref = &a;
18
19     let b = *&a;
20
21     let b = *&get_number();
22
23     let b = *get_reference(&a);
24
25     let bytes : Vec<usize> = vec![1, 2, 3, 4];
26     let b = *&bytes[1..2][0];
27
28     //This produces a suggestion of 'let b = (a);' which
29     //will trigger the 'unused_parens' lint
30     let b = *&(a);
31
32     let b = *(&a);
33
34     let b = *((&a));
35
36     let b = *&&a;
37
38     let b = **&aref;
39
40     //This produces a suggestion of 'let b = *&a;' which
41     //will trigger the 'clippy::deref_addrof' lint again
42     let b = **&&a;
43
44     {
45         let mut x = 10;
46         let y = *&mut x;
47     }
48
49     {
50         //This produces a suggestion of 'let y = *&mut x' which
51         //will trigger the 'clippy::deref_addrof' lint again
52         let mut x = 10;
53         let y = **&mut &mut x;
54     }
55 }