@@ -14,11 +14,12 @@ use rustc_span::symbol::kw;
1414
1515declare_clippy_lint ! {
1616 /// ### What it does
17- /// Checks for manual implementations of `Clone` when `Copy` is already implemented.
17+ /// Checks for non-canonical implementations of `Clone` when `Copy` is already implemented.
1818 ///
1919 /// ### 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.
2223 ///
2324 /// ### Example
2425 /// ```rust,ignore
@@ -47,26 +48,22 @@ declare_clippy_lint! {
4748 /// impl Copy for A {}
4849 /// ```
4950 #[ clippy:: version = "1.72.0" ]
50- pub INCORRECT_CLONE_IMPL_ON_COPY_TYPE ,
51- correctness ,
52- "manual implementation of `Clone` on a `Copy` type"
51+ pub NON_CANONICAL_CLONE_IMPL ,
52+ suspicious ,
53+ "non-canonical implementation of `Clone` on a `Copy` type"
5354}
5455declare_clippy_lint ! {
5556 /// ### What it does
56- /// Checks for manual implementations of both `PartialOrd` and `Ord` when only `Ord` is
57- /// necessary.
57+ /// Checks for non-canonical implementations of `PartialOrd` when `Ord` is already implemented.
5858 ///
5959 /// ### Why is this bad?
6060 /// If both `PartialOrd` and `Ord` are implemented, they must agree. This is commonly done by
6161 /// wrapping the result of `cmp` in `Some` for `partial_cmp`. Not doing this may silently
6262 /// introduce an error upon refactoring.
6363 ///
6464 /// ### 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.
65+ /// Code that calls the `.into()` method instead will be flagged, despite `.into()` wrapping it
66+ /// in `Some`.
7067 ///
7168 /// ### Example
7269 /// ```rust
@@ -108,13 +105,13 @@ declare_clippy_lint! {
108105 /// }
109106 /// ```
110107 #[ clippy:: version = "1.72.0" ]
111- pub INCORRECT_PARTIAL_ORD_IMPL_ON_ORD_TYPE ,
112- correctness ,
113- "manual implementation of `PartialOrd` when `Ord` is already implemented "
108+ pub NON_CANONICAL_PARTIAL_ORD_IMPL ,
109+ suspicious ,
110+ "non-canonical implementation of `PartialOrd` on an `Ord` type "
114111}
115- declare_lint_pass ! ( IncorrectImpls => [ INCORRECT_CLONE_IMPL_ON_COPY_TYPE , INCORRECT_PARTIAL_ORD_IMPL_ON_ORD_TYPE ] ) ;
112+ declare_lint_pass ! ( NonCanonicalImpls => [ NON_CANONICAL_CLONE_IMPL , NON_CANONICAL_PARTIAL_ORD_IMPL ] ) ;
116113
117- impl LateLintPass < ' _ > for IncorrectImpls {
114+ impl LateLintPass < ' _ > for NonCanonicalImpls {
118115 #[ expect( clippy:: too_many_lines) ]
119116 fn check_impl_item ( & mut self , cx : & LateContext < ' _ > , impl_item : & ImplItem < ' _ > ) {
120117 let Some ( Node :: Item ( item) ) = get_parent_node ( cx. tcx , impl_item. hir_id ( ) ) else {
@@ -155,9 +152,9 @@ impl LateLintPass<'_> for IncorrectImpls {
155152 { } else {
156153 span_lint_and_sugg (
157154 cx,
158- INCORRECT_CLONE_IMPL_ON_COPY_TYPE ,
155+ NON_CANONICAL_CLONE_IMPL ,
159156 block. span ,
160- "incorrect implementation of `clone` on a `Copy` type" ,
157+ "non-canonical implementation of `clone` on a `Copy` type" ,
161158 "change this to" ,
162159 "{ *self }" . to_owned ( ) ,
163160 Applicability :: MaybeIncorrect ,
@@ -170,9 +167,9 @@ impl LateLintPass<'_> for IncorrectImpls {
170167 if impl_item. ident . name == sym:: clone_from {
171168 span_lint_and_sugg (
172169 cx,
173- INCORRECT_CLONE_IMPL_ON_COPY_TYPE ,
170+ NON_CANONICAL_CLONE_IMPL ,
174171 impl_item. span ,
175- "incorrect implementation of `clone_from` on a `Copy` type" ,
172+ "unnecessary implementation of `clone_from` on a `Copy` type" ,
176173 "remove it" ,
177174 String :: new ( ) ,
178175 Applicability :: MaybeIncorrect ,
@@ -218,9 +215,9 @@ impl LateLintPass<'_> for IncorrectImpls {
218215
219216 span_lint_and_then (
220217 cx,
221- INCORRECT_PARTIAL_ORD_IMPL_ON_ORD_TYPE ,
218+ NON_CANONICAL_PARTIAL_ORD_IMPL ,
222219 item. span ,
223- "incorrect implementation of `partial_cmp` on an `Ord` type" ,
220+ "non-canonical implementation of `partial_cmp` on an `Ord` type" ,
224221 |diag| {
225222 let [ _, other] = body. params else {
226223 return ;
0 commit comments