Skip to content

Commit 001b6ee

Browse files
committed
Rename incorrect_impls to manual_impls, move them to warn by default
1 parent d9e6aac commit 001b6ee

22 files changed

+135
-113
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5065,6 +5065,7 @@ Released 2018-09-13
50655065
[`manual_async_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn
50665066
[`manual_bits`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_bits
50675067
[`manual_clamp`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp
5068+
[`manual_clone_impl_on_copy_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_clone_impl_on_copy_type
50685069
[`manual_filter`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter
50695070
[`manual_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter_map
50705071
[`manual_find`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find
@@ -5081,6 +5082,7 @@ Released 2018-09-13
50815082
[`manual_next_back`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_next_back
50825083
[`manual_non_exhaustive`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive
50835084
[`manual_ok_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_or
5085+
[`manual_partial_ord_impl_on_ord_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_partial_ord_impl_on_ord_type
50845086
[`manual_range_contains`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains
50855087
[`manual_range_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_patterns
50865088
[`manual_rem_euclid`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_rem_euclid

clippy_lints/src/declared_lints.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
209209
crate::implicit_saturating_add::IMPLICIT_SATURATING_ADD_INFO,
210210
crate::implicit_saturating_sub::IMPLICIT_SATURATING_SUB_INFO,
211211
crate::inconsistent_struct_constructor::INCONSISTENT_STRUCT_CONSTRUCTOR_INFO,
212-
crate::incorrect_impls::INCORRECT_CLONE_IMPL_ON_COPY_TYPE_INFO,
213-
crate::incorrect_impls::INCORRECT_PARTIAL_ORD_IMPL_ON_ORD_TYPE_INFO,
214212
crate::index_refutable_slice::INDEX_REFUTABLE_SLICE_INFO,
215213
crate::indexing_slicing::INDEXING_SLICING_INFO,
216214
crate::indexing_slicing::OUT_OF_BOUNDS_INDEXING_INFO,
@@ -279,6 +277,8 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
279277
crate::manual_clamp::MANUAL_CLAMP_INFO,
280278
crate::manual_float_methods::MANUAL_IS_FINITE_INFO,
281279
crate::manual_float_methods::MANUAL_IS_INFINITE_INFO,
280+
crate::manual_impls::MANUAL_CLONE_IMPL_ON_COPY_TYPE_INFO,
281+
crate::manual_impls::MANUAL_PARTIAL_ORD_IMPL_ON_ORD_TYPE_INFO,
282282
crate::manual_is_ascii_check::MANUAL_IS_ASCII_CHECK_INFO,
283283
crate::manual_let_else::MANUAL_LET_ELSE_INFO,
284284
crate::manual_main_separator_str::MANUAL_MAIN_SEPARATOR_STR_INFO,

clippy_lints/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ mod implicit_return;
153153
mod implicit_saturating_add;
154154
mod implicit_saturating_sub;
155155
mod inconsistent_struct_constructor;
156-
mod incorrect_impls;
157156
mod index_refutable_slice;
158157
mod indexing_slicing;
159158
mod infinite_iter;
@@ -188,6 +187,7 @@ mod manual_async_fn;
188187
mod manual_bits;
189188
mod manual_clamp;
190189
mod manual_float_methods;
190+
mod manual_impls;
191191
mod manual_is_ascii_check;
192192
mod manual_let_else;
193193
mod manual_main_separator_str;
@@ -1066,7 +1066,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
10661066
avoid_breaking_exported_api,
10671067
))
10681068
});
1069-
store.register_late_pass(|_| Box::new(incorrect_impls::IncorrectImpls));
1069+
store.register_late_pass(|_| Box::new(manual_impls::ManualImpls));
10701070
store.register_late_pass(move |_| {
10711071
Box::new(single_call_fn::SingleCallFn {
10721072
avoid_breaking_exported_api,

clippy_lints/src/incorrect_impls.rs renamed to clippy_lints/src/manual_impls.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ declare_clippy_lint! {
1717
/// Checks for manual 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,8 +48,8 @@ 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,
51+
pub MANUAL_CLONE_IMPL_ON_COPY_TYPE,
52+
complexity,
5253
"manual implementation of `Clone` on a `Copy` type"
5354
}
5455
declare_clippy_lint! {
@@ -62,11 +63,8 @@ declare_clippy_lint! {
6263
/// introduce an error upon refactoring.
6364
///
6465
/// ### 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`.
7068
///
7169
/// ### Example
7270
/// ```rust
@@ -108,13 +106,13 @@ declare_clippy_lint! {
108106
/// }
109107
/// ```
110108
#[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,
113111
"manual implementation of `PartialOrd` when `Ord` is already implemented"
114112
}
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]);
116114

117-
impl LateLintPass<'_> for IncorrectImpls {
115+
impl LateLintPass<'_> for ManualImpls {
118116
#[expect(clippy::too_many_lines)]
119117
fn check_impl_item(&mut self, cx: &LateContext<'_>, impl_item: &ImplItem<'_>) {
120118
let Some(Node::Item(item)) = get_parent_node(cx.tcx, impl_item.hir_id()) else {
@@ -155,9 +153,9 @@ impl LateLintPass<'_> for IncorrectImpls {
155153
{} else {
156154
span_lint_and_sugg(
157155
cx,
158-
INCORRECT_CLONE_IMPL_ON_COPY_TYPE,
156+
MANUAL_CLONE_IMPL_ON_COPY_TYPE,
159157
block.span,
160-
"incorrect implementation of `clone` on a `Copy` type",
158+
"manual implementation of `clone` on a `Copy` type",
161159
"change this to",
162160
"{ *self }".to_owned(),
163161
Applicability::MaybeIncorrect,
@@ -170,9 +168,9 @@ impl LateLintPass<'_> for IncorrectImpls {
170168
if impl_item.ident.name == sym::clone_from {
171169
span_lint_and_sugg(
172170
cx,
173-
INCORRECT_CLONE_IMPL_ON_COPY_TYPE,
171+
MANUAL_CLONE_IMPL_ON_COPY_TYPE,
174172
impl_item.span,
175-
"incorrect implementation of `clone_from` on a `Copy` type",
173+
"unneeded implementation of `clone_from` on a `Copy` type",
176174
"remove it",
177175
String::new(),
178176
Applicability::MaybeIncorrect,
@@ -218,9 +216,9 @@ impl LateLintPass<'_> for IncorrectImpls {
218216

219217
span_lint_and_then(
220218
cx,
221-
INCORRECT_PARTIAL_ORD_IMPL_ON_ORD_TYPE,
219+
MANUAL_PARTIAL_ORD_IMPL_ON_ORD_TYPE,
222220
item.span,
223-
"incorrect implementation of `partial_cmp` on an `Ord` type",
221+
"manual implementation of `partial_cmp` on an `Ord` type",
224222
|diag| {
225223
let [_, other] = body.params else {
226224
return;

clippy_lints/src/renamed_lints.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
1515
("clippy::eval_order_dependence", "clippy::mixed_read_write_in_expression"),
1616
("clippy::identity_conversion", "clippy::useless_conversion"),
1717
("clippy::if_let_some_result", "clippy::match_result_ok"),
18+
("clippy::incorrect_clone_impl_on_copy_type", "clippy::manual_clone_impl_on_copy_type"),
19+
("clippy::incorrect_partial_ord_impl_on_ord_type", "clippy::manual_partial_ord_impl_on_ord_type"),
1820
("clippy::integer_arithmetic", "clippy::arithmetic_side_effects"),
1921
("clippy::logic_bug", "clippy::overly_complex_bool_expr"),
2022
("clippy::new_without_default_derive", "clippy::new_without_default"),
@@ -38,12 +40,12 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
3840
("clippy::drop_bounds", "drop_bounds"),
3941
("clippy::drop_copy", "dropping_copy_types"),
4042
("clippy::drop_ref", "dropping_references"),
43+
("clippy::fn_null_check", "useless_ptr_null_checks"),
4144
("clippy::for_loop_over_option", "for_loops_over_fallibles"),
4245
("clippy::for_loop_over_result", "for_loops_over_fallibles"),
4346
("clippy::for_loops_over_fallibles", "for_loops_over_fallibles"),
4447
("clippy::forget_copy", "forgetting_copy_types"),
4548
("clippy::forget_ref", "forgetting_references"),
46-
("clippy::fn_null_check", "useless_ptr_null_checks"),
4749
("clippy::into_iter_on_array", "array_into_iter"),
4850
("clippy::invalid_atomic_ordering", "invalid_atomic_ordering"),
4951
("clippy::invalid_ref", "invalid_value"),

tests/ui/bool_comparison.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(clippy::needless_if)]
22
#![warn(clippy::bool_comparison)]
3-
#![allow(clippy::incorrect_partial_ord_impl_on_ord_type)]
3+
#![allow(clippy::manual_partial_ord_impl_on_ord_type)]
44

55
fn main() {
66
let x = true;

tests/ui/bool_comparison.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(clippy::needless_if)]
22
#![warn(clippy::bool_comparison)]
3-
#![allow(clippy::incorrect_partial_ord_impl_on_ord_type)]
3+
#![allow(clippy::manual_partial_ord_impl_on_ord_type)]
44

55
fn main() {
66
let x = true;

tests/ui/clone_on_copy_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(clippy::incorrect_clone_impl_on_copy_type)]
1+
#![allow(clippy::manual_clone_impl_on_copy_type)]
22

33
use std::fmt;
44
use std::marker::PhantomData;

tests/ui/derive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(
2-
clippy::incorrect_clone_impl_on_copy_type,
3-
clippy::incorrect_partial_ord_impl_on_ord_type,
2+
clippy::manual_clone_impl_on_copy_type,
3+
clippy::manual_partial_ord_impl_on_ord_type,
44
dead_code
55
)]
66
#![warn(clippy::expl_impl_clone_on_copy)]

tests/ui/derive_ord_xor_partial_ord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![warn(clippy::derive_ord_xor_partial_ord)]
22
#![allow(clippy::unnecessary_wraps)]
3-
#![allow(clippy::incorrect_partial_ord_impl_on_ord_type)]
3+
#![allow(clippy::manual_partial_ord_impl_on_ord_type)]
44

55
use std::cmp::Ordering;
66

tests/ui/incorrect_partial_ord_impl_on_ord_type_fully_qual.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: incorrect implementation of `partial_cmp` on an `Ord` type
1+
error: manual implementation of `partial_cmp` on an `Ord` type
22
--> $DIR/incorrect_partial_ord_impl_on_ord_type_fully_qual.rs:23:1
33
|
44
LL | / impl PartialOrd for A {
@@ -12,9 +12,9 @@ LL | || }
1212
LL | | }
1313
| |__^
1414
|
15-
= note: `#[deny(clippy::incorrect_partial_ord_impl_on_ord_type)]` on by default
15+
= note: `-D clippy::manual-partial-ord-impl-on-ord-type` implied by `-D warnings`
1616

17-
error: incorrect implementation of `partial_cmp` on an `Ord` type
17+
error: manual implementation of `partial_cmp` on an `Ord` type
1818
--> $DIR/incorrect_partial_ord_impl_on_ord_type_fully_qual.rs:46:1
1919
|
2020
LL | / impl PartialOrd for B {

tests/ui/incorrect_clone_impl_on_copy_type.stderr renamed to tests/ui/manual_clone_impl_on_copy_type.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
error: incorrect implementation of `clone` on a `Copy` type
2-
--> $DIR/incorrect_clone_impl_on_copy_type.rs:9:29
1+
error: manual implementation of `clone` on a `Copy` type
2+
--> $DIR/manual_clone_impl_on_copy_type.rs:9:29
33
|
44
LL | fn clone(&self) -> Self {
55
| _____________________________^
66
LL | | Self(self.0)
77
LL | | }
88
| |_____^ help: change this to: `{ *self }`
99
|
10-
= note: `#[deny(clippy::incorrect_clone_impl_on_copy_type)]` on by default
10+
= note: `-D clippy::manual-clone-impl-on-copy-type` implied by `-D warnings`
1111

12-
error: incorrect implementation of `clone_from` on a `Copy` type
13-
--> $DIR/incorrect_clone_impl_on_copy_type.rs:13:5
12+
error: unneeded implementation of `clone_from` on a `Copy` type
13+
--> $DIR/manual_clone_impl_on_copy_type.rs:13:5
1414
|
1515
LL | / fn clone_from(&mut self, source: &Self) {
1616
LL | | source.clone();
1717
LL | | *self = source.clone();
1818
LL | | }
1919
| |_____^ help: remove it
2020

21-
error: incorrect implementation of `clone` on a `Copy` type
22-
--> $DIR/incorrect_clone_impl_on_copy_type.rs:80:29
21+
error: manual implementation of `clone` on a `Copy` type
22+
--> $DIR/manual_clone_impl_on_copy_type.rs:80:29
2323
|
2424
LL | fn clone(&self) -> Self {
2525
| _____________________________^
2626
LL | | Self(self.0)
2727
LL | | }
2828
| |_____^ help: change this to: `{ *self }`
2929

30-
error: incorrect implementation of `clone_from` on a `Copy` type
31-
--> $DIR/incorrect_clone_impl_on_copy_type.rs:84:5
30+
error: unneeded implementation of `clone_from` on a `Copy` type
31+
--> $DIR/manual_clone_impl_on_copy_type.rs:84:5
3232
|
3333
LL | / fn clone_from(&mut self, source: &Self) {
3434
LL | | source.clone();

tests/ui/incorrect_partial_ord_impl_on_ord_type.stderr renamed to tests/ui/manual_partial_ord_impl_on_ord_type.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
error: incorrect implementation of `partial_cmp` on an `Ord` type
2-
--> $DIR/incorrect_partial_ord_impl_on_ord_type.rs:16:1
1+
error: manual implementation of `partial_cmp` on an `Ord` type
2+
--> $DIR/manual_partial_ord_impl_on_ord_type.rs:16:1
33
|
44
LL | / impl PartialOrd for A {
55
LL | | fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
@@ -10,10 +10,10 @@ LL | || }
1010
LL | | }
1111
| |__^
1212
|
13-
= note: `#[deny(clippy::incorrect_partial_ord_impl_on_ord_type)]` on by default
13+
= note: `-D clippy::manual-partial-ord-impl-on-ord-type` implied by `-D warnings`
1414

15-
error: incorrect implementation of `partial_cmp` on an `Ord` type
16-
--> $DIR/incorrect_partial_ord_impl_on_ord_type.rs:50:1
15+
error: manual implementation of `partial_cmp` on an `Ord` type
16+
--> $DIR/manual_partial_ord_impl_on_ord_type.rs:50:1
1717
|
1818
LL | / impl PartialOrd for C {
1919
LL | | fn partial_cmp(&self, _: &Self) -> Option<Ordering> {

tests/ui/rename.fixed

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#![allow(clippy::mixed_read_write_in_expression)]
1515
#![allow(clippy::useless_conversion)]
1616
#![allow(clippy::match_result_ok)]
17+
#![allow(clippy::manual_clone_impl_on_copy_type)]
18+
#![allow(clippy::manual_partial_ord_impl_on_ord_type)]
1719
#![allow(clippy::arithmetic_side_effects)]
1820
#![allow(clippy::overly_complex_bool_expr)]
1921
#![allow(clippy::new_without_default)]
@@ -33,10 +35,10 @@
3335
#![allow(drop_bounds)]
3436
#![allow(dropping_copy_types)]
3537
#![allow(dropping_references)]
38+
#![allow(useless_ptr_null_checks)]
3639
#![allow(for_loops_over_fallibles)]
3740
#![allow(forgetting_copy_types)]
3841
#![allow(forgetting_references)]
39-
#![allow(useless_ptr_null_checks)]
4042
#![allow(array_into_iter)]
4143
#![allow(invalid_atomic_ordering)]
4244
#![allow(invalid_value)]
@@ -62,6 +64,8 @@
6264
#![warn(clippy::mixed_read_write_in_expression)]
6365
#![warn(clippy::useless_conversion)]
6466
#![warn(clippy::match_result_ok)]
67+
#![warn(clippy::manual_clone_impl_on_copy_type)]
68+
#![warn(clippy::manual_partial_ord_impl_on_ord_type)]
6569
#![warn(clippy::arithmetic_side_effects)]
6670
#![warn(clippy::overly_complex_bool_expr)]
6771
#![warn(clippy::new_without_default)]
@@ -85,12 +89,12 @@
8589
#![warn(drop_bounds)]
8690
#![warn(dropping_copy_types)]
8791
#![warn(dropping_references)]
92+
#![warn(useless_ptr_null_checks)]
8893
#![warn(for_loops_over_fallibles)]
8994
#![warn(for_loops_over_fallibles)]
9095
#![warn(for_loops_over_fallibles)]
9196
#![warn(forgetting_copy_types)]
9297
#![warn(forgetting_references)]
93-
#![warn(useless_ptr_null_checks)]
9498
#![warn(array_into_iter)]
9599
#![warn(invalid_atomic_ordering)]
96100
#![warn(invalid_value)]

tests/ui/rename.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#![allow(clippy::mixed_read_write_in_expression)]
1515
#![allow(clippy::useless_conversion)]
1616
#![allow(clippy::match_result_ok)]
17+
#![allow(clippy::manual_clone_impl_on_copy_type)]
18+
#![allow(clippy::manual_partial_ord_impl_on_ord_type)]
1719
#![allow(clippy::arithmetic_side_effects)]
1820
#![allow(clippy::overly_complex_bool_expr)]
1921
#![allow(clippy::new_without_default)]
@@ -33,10 +35,10 @@
3335
#![allow(drop_bounds)]
3436
#![allow(dropping_copy_types)]
3537
#![allow(dropping_references)]
38+
#![allow(useless_ptr_null_checks)]
3639
#![allow(for_loops_over_fallibles)]
3740
#![allow(forgetting_copy_types)]
3841
#![allow(forgetting_references)]
39-
#![allow(useless_ptr_null_checks)]
4042
#![allow(array_into_iter)]
4143
#![allow(invalid_atomic_ordering)]
4244
#![allow(invalid_value)]
@@ -62,6 +64,8 @@
6264
#![warn(clippy::eval_order_dependence)]
6365
#![warn(clippy::identity_conversion)]
6466
#![warn(clippy::if_let_some_result)]
67+
#![warn(clippy::incorrect_clone_impl_on_copy_type)]
68+
#![warn(clippy::incorrect_partial_ord_impl_on_ord_type)]
6569
#![warn(clippy::integer_arithmetic)]
6670
#![warn(clippy::logic_bug)]
6771
#![warn(clippy::new_without_default_derive)]
@@ -85,12 +89,12 @@
8589
#![warn(clippy::drop_bounds)]
8690
#![warn(clippy::drop_copy)]
8791
#![warn(clippy::drop_ref)]
92+
#![warn(clippy::fn_null_check)]
8893
#![warn(clippy::for_loop_over_option)]
8994
#![warn(clippy::for_loop_over_result)]
9095
#![warn(clippy::for_loops_over_fallibles)]
9196
#![warn(clippy::forget_copy)]
9297
#![warn(clippy::forget_ref)]
93-
#![warn(clippy::fn_null_check)]
9498
#![warn(clippy::into_iter_on_array)]
9599
#![warn(clippy::invalid_atomic_ordering)]
96100
#![warn(clippy::invalid_ref)]

0 commit comments

Comments
 (0)