@@ -17,8 +17,9 @@ declare_clippy_lint! {
17
17
/// Checks for manual implementations of `Clone` when `Copy` is already implemented.
18
18
///
19
19
/// ### Why is this bad?
20
- /// If both `Clone` and `Copy` are implemented, they must agree. This is done by dereferencing
21
- /// `self` in `Clone`'s implementation. Anything else is incorrect.
20
+ /// If both `Clone` and `Copy` are implemented, they must agree. This can done by dereferencing
21
+ /// `self` in `Clone`'s implementation, which will avoid any possibility of the implementations
22
+ /// becoming out of sync.
22
23
///
23
24
/// ### Example
24
25
/// ```rust,ignore
@@ -47,8 +48,8 @@ declare_clippy_lint! {
47
48
/// impl Copy for A {}
48
49
/// ```
49
50
#[ clippy:: version = "1.72.0" ]
50
- pub INCORRECT_CLONE_IMPL_ON_COPY_TYPE ,
51
- correctness ,
51
+ pub MANUAL_CLONE_IMPL_ON_COPY_TYPE ,
52
+ complexity ,
52
53
"manual implementation of `Clone` on a `Copy` type"
53
54
}
54
55
declare_clippy_lint ! {
@@ -62,11 +63,8 @@ declare_clippy_lint! {
62
63
/// introduce an error upon refactoring.
63
64
///
64
65
/// ### Known issues
65
- /// Code that calls the `.into()` method instead will be flagged as incorrect, despite `.into()`
66
- /// wrapping it in `Some`.
67
- ///
68
- /// ### Limitations
69
- /// Will not lint if `Self` and `Rhs` do not have the same type.
66
+ /// Code that calls the `.into()` method instead will be flagged, despite `.into()` wrapping it
67
+ /// in `Some`.
70
68
///
71
69
/// ### Example
72
70
/// ```rust
@@ -108,13 +106,13 @@ declare_clippy_lint! {
108
106
/// }
109
107
/// ```
110
108
#[ clippy:: version = "1.72.0" ]
111
- pub INCORRECT_PARTIAL_ORD_IMPL_ON_ORD_TYPE ,
112
- correctness ,
109
+ pub MANUAL_PARTIAL_ORD_IMPL_ON_ORD_TYPE ,
110
+ complexity ,
113
111
"manual implementation of `PartialOrd` when `Ord` is already implemented"
114
112
}
115
- declare_lint_pass ! ( IncorrectImpls => [ INCORRECT_CLONE_IMPL_ON_COPY_TYPE , INCORRECT_PARTIAL_ORD_IMPL_ON_ORD_TYPE ] ) ;
113
+ declare_lint_pass ! ( ManualImpls => [ MANUAL_CLONE_IMPL_ON_COPY_TYPE , MANUAL_PARTIAL_ORD_IMPL_ON_ORD_TYPE ] ) ;
116
114
117
- impl LateLintPass < ' _ > for IncorrectImpls {
115
+ impl LateLintPass < ' _ > for ManualImpls {
118
116
#[ expect( clippy:: too_many_lines) ]
119
117
fn check_impl_item ( & mut self , cx : & LateContext < ' _ > , impl_item : & ImplItem < ' _ > ) {
120
118
let Some ( Node :: Item ( item) ) = get_parent_node ( cx. tcx , impl_item. hir_id ( ) ) else {
@@ -155,9 +153,9 @@ impl LateLintPass<'_> for IncorrectImpls {
155
153
{ } else {
156
154
span_lint_and_sugg (
157
155
cx,
158
- INCORRECT_CLONE_IMPL_ON_COPY_TYPE ,
156
+ MANUAL_CLONE_IMPL_ON_COPY_TYPE ,
159
157
block. span ,
160
- "incorrect implementation of `clone` on a `Copy` type" ,
158
+ "manual implementation of `clone` on a `Copy` type" ,
161
159
"change this to" ,
162
160
"{ *self }" . to_owned ( ) ,
163
161
Applicability :: MaybeIncorrect ,
@@ -170,9 +168,9 @@ impl LateLintPass<'_> for IncorrectImpls {
170
168
if impl_item. ident . name == sym:: clone_from {
171
169
span_lint_and_sugg (
172
170
cx,
173
- INCORRECT_CLONE_IMPL_ON_COPY_TYPE ,
171
+ MANUAL_CLONE_IMPL_ON_COPY_TYPE ,
174
172
impl_item. span ,
175
- "incorrect implementation of `clone_from` on a `Copy` type" ,
173
+ "unneeded implementation of `clone_from` on a `Copy` type" ,
176
174
"remove it" ,
177
175
String :: new ( ) ,
178
176
Applicability :: MaybeIncorrect ,
@@ -218,9 +216,9 @@ impl LateLintPass<'_> for IncorrectImpls {
218
216
219
217
span_lint_and_then (
220
218
cx,
221
- INCORRECT_PARTIAL_ORD_IMPL_ON_ORD_TYPE ,
219
+ MANUAL_PARTIAL_ORD_IMPL_ON_ORD_TYPE ,
222
220
item. span ,
223
- "incorrect implementation of `partial_cmp` on an `Ord` type" ,
221
+ "manual implementation of `partial_cmp` on an `Ord` type" ,
224
222
|diag| {
225
223
let [ _, other] = body. params else {
226
224
return ;
0 commit comments