Skip to content

Commit 662267f

Browse files
committed
msg
1 parent 75d75b8 commit 662267f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

clippy_lints/src/needless_deref.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ declare_clippy_lint! {
1212
/// Checks for `&*(&T)`.
1313
///
1414
/// ### 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`.
1617
/// if you want to deref explicitly, `&** (&T)` is what you need.
18+
/// If you want to reborrow, `&T` is enough (`&T` is Copy).
1719
///
1820
/// ### Known problems
1921
/// None.
@@ -34,7 +36,7 @@ declare_clippy_lint! {
3436
/// ```
3537
pub NEEDLESS_DEREF,
3638
complexity,
37-
"remove needless deref"
39+
"deref on an immutable reference returns the same type as itself"
3840
}
3941

4042
declare_lint_pass!(NeedlessDeref => [NEEDLESS_DEREF]);
@@ -69,7 +71,7 @@ impl LateLintPass<'_> for NeedlessDeref {
6971
cx,
7072
NEEDLESS_DEREF,
7173
e.span,
72-
"reference on a de-referenced",
74+
"deref on an immutable borrow",
7375
None,
7476
&format!(
7577
"consider using `{}` if you would like to deref\nconsider using `{}` if you would like to reborrow",

tests/ui/needless_deref.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: reference on a de-referenced
1+
error: deref on an immutable borrow
22
--> $DIR/needless_deref.rs:6:18
33
|
44
LL | let _b = &*a;
@@ -8,7 +8,7 @@ LL | let _b = &*a;
88
= help: consider using `&**a` if you would like to deref
99
consider using `a` if you would like to reborrow
1010

11-
error: reference on a de-referenced
11+
error: deref on an immutable borrow
1212
--> $DIR/needless_deref.rs:9:23
1313
|
1414
LL | let a: &str = &*s;

0 commit comments

Comments
 (0)