@@ -19,56 +19,58 @@ fn main() {
19
19
let b = * & a;
20
20
//~^ERROR immediately dereferencing a reference
21
21
//~|HELP try this
22
- //~|SUGGESTION a
22
+ //~|SUGGESTION let b = a;
23
23
24
24
let b = * & get_number ( ) ;
25
25
//~^ERROR immediately dereferencing a reference
26
26
//~|HELP try this
27
- //~|SUGGESTION get_number()
27
+ //~|SUGGESTION let b = get_number();
28
28
29
29
let b = * get_reference ( & a) ;
30
30
31
31
let bytes : Vec < usize > = vec ! [ 1 , 2 , 3 , 4 ] ;
32
32
let b = * & bytes[ 1 ..2 ] [ 0 ] ;
33
33
//~^ERROR immediately dereferencing a reference
34
34
//~|HELP try this
35
- //~|SUGGESTION bytes[1..2][0]
35
+ //~|SUGGESTION let b = bytes[1..2][0];
36
36
37
37
let b = * ( & a) ;
38
38
//~^ERROR immediately dereferencing a reference
39
39
//~|HELP try this
40
- //~|SUGGESTION a
40
+ //~|SUGGESTION let b = a;
41
41
42
42
let b = * & & a;
43
43
//~^ERROR immediately dereferencing a reference
44
44
//~|HELP try this
45
- //~|SUGGESTION &a
45
+ //~|SUGGESTION let b = &a;
46
46
47
47
let b = * * & aref;
48
48
//~^ERROR immediately dereferencing a reference
49
49
//~|HELP try this
50
- //~|SUGGESTION aref
50
+ //~|SUGGESTION let b = * aref;
51
51
52
- //This produces a suggestion of 'let b = *&a;' which is still incorrect
52
+ //This produces a suggestion of 'let b = *&a;' which
53
+ //will trigger the 'deref_addrof' lint again
53
54
let b = * * & & a;
54
55
//~^ERROR immediately dereferencing a reference
55
56
//~|HELP try this
56
- //~|SUGGESTION a
57
+ //~|SUGGESTION let b = *&a;
57
58
58
59
{
59
60
let mut x = 10 ;
60
61
let y = * & mut x;
61
62
//~^ERROR immediately dereferencing a reference
62
63
//~|HELP try this
63
- //~|SUGGESTION x
64
+ //~|SUGGESTION let y = x;
64
65
}
65
66
66
67
{
67
- //This produces a suggestion of 'let y = *&mut x' which is still incorrect
68
+ //This produces a suggestion of 'let y = *&mut x' which
69
+ //will trigger the 'deref_addrof' lint again
68
70
let mut x = 10 ;
69
71
let y = * * & mut & mut x;
70
72
//~^ERROR immediately dereferencing a reference
71
73
//~|HELP try this
72
- //~|SUGGESTION x
74
+ //~|SUGGESTION let y = *&mut x;
73
75
}
74
76
}
0 commit comments