File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -12,8 +12,10 @@ declare_clippy_lint! {
12
12
/// Checks for `&*(&T)`.
13
13
///
14
14
/// ### Why is this bad?
15
- /// If you just want to reborrow, `&T` is enough (`&T` is Copy).
15
+ /// When people deref on an immutable reference `&T`, they may expect return `&U`.
16
+ /// Accutually `&* (&T)` is still `&T`.
16
17
/// if you want to deref explicitly, `&** (&T)` is what you need.
18
+ /// If you want to reborrow, `&T` is enough (`&T` is Copy).
17
19
///
18
20
/// ### Known problems
19
21
/// None.
@@ -34,7 +36,7 @@ declare_clippy_lint! {
34
36
/// ```
35
37
pub NEEDLESS_DEREF ,
36
38
complexity,
37
- "remove needless deref "
39
+ "deref on an immutable reference returns the same type as itself "
38
40
}
39
41
40
42
declare_lint_pass ! ( NeedlessDeref => [ NEEDLESS_DEREF ] ) ;
@@ -69,7 +71,7 @@ impl LateLintPass<'_> for NeedlessDeref {
69
71
cx,
70
72
NEEDLESS_DEREF ,
71
73
e. span,
72
- "reference on a de-referenced " ,
74
+ "deref on an immutable borrow " ,
73
75
None ,
74
76
& format!(
75
77
"consider using `{}` if you would like to deref\n consider using `{}` if you would like to reborrow" ,
Original file line number Diff line number Diff line change 1
- error: reference on a de-referenced
1
+ error: deref on an immutable borrow
2
2
--> $DIR/needless_deref.rs:6:18
3
3
|
4
4
LL | let _b = &*a;
@@ -8,7 +8,7 @@ LL | let _b = &*a;
8
8
= help: consider using `&**a` if you would like to deref
9
9
consider using `a` if you would like to reborrow
10
10
11
- error: reference on a de-referenced
11
+ error: deref on an immutable borrow
12
12
--> $DIR/needless_deref.rs:9:23
13
13
|
14
14
LL | let a: &str = &*s;
You can’t perform that action at this time.
0 commit comments