File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ declare_lint! {
1616 ///
1717 /// ```rust
1818 /// # #![allow(unused)]
19- /// #![warn(noop_method_call)]
2019 /// struct Foo;
2120 /// let foo = &Foo;
2221 /// let clone: &Foo = foo.clone();
@@ -37,9 +36,25 @@ declare_lint! {
3736}
3837
3938declare_lint ! {
40- /// The `suspicious_double_ref_op` lint checks for usage of `.clone()` on an `&&T`,
41- /// which copies the inner `&T`, instead of cloning the underlying `T` and
42- /// can be confusing.
39+ /// The `suspicious_double_ref_op` lint checks for usage of `.clone()`/`.borrow()`/`.deref()`
40+ /// on an `&&T` when `T: !Deref/Borrow/Clone`, which means the call will copy the inner `&T`,
41+ /// instead of performing the operation on the underlying `T` and can be confusing.
42+ ///
43+ /// ### Example
44+ ///
45+ /// ```rust
46+ /// # #![allow(unused)]
47+ /// struct Foo;
48+ /// let foo = &&Foo;
49+ /// let clone: &Foo = foo.clone();
50+ /// ```
51+ ///
52+ /// {{produces}}
53+ ///
54+ /// ### Explanation
55+ ///
56+ /// Since `Foo` doesn't implement `Clone`, running `.clone()` only dereferences the double
57+ /// reference, instead of cloning the inner type which should be what was intended.
4358 pub SUSPICIOUS_DOUBLE_REF_OP ,
4459 Warn ,
4560 "using `clone` on `&&T`"
You can’t perform that action at this time.
0 commit comments