Skip to content

Commit bb01aca

Browse files
committed
HACK: Move buggy lints to nursery
Those lints are trait_duplication_in_bounds and type_repetition_in_bounds. I don't think those can be fixed on the Clippy side alone, but need changes in the compiler. So let's move them to nursery to get the sync through and then fix them on the rustc side. Also adds a regression test that has to be fixed before they can be moved back to pedantic.
1 parent 7e017db commit bb01aca

7 files changed

+28
-6
lines changed

clippy_lints/src/lib.register_nursery.rs

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
2828
LintId::of(strings::STRING_LIT_AS_BYTES),
2929
LintId::of(suspicious_operation_groupings::SUSPICIOUS_OPERATION_GROUPINGS),
3030
LintId::of(trailing_empty_array::TRAILING_EMPTY_ARRAY),
31+
LintId::of(trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS),
32+
LintId::of(trait_bounds::TYPE_REPETITION_IN_BOUNDS),
3133
LintId::of(transmute::TRANSMUTE_UNDEFINED_REPR),
3234
LintId::of(transmute::USELESS_TRANSMUTE),
3335
LintId::of(use_self::USE_SELF),

clippy_lints/src/lib.register_pedantic.rs

-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), vec![
8484
LintId::of(semicolon_if_nothing_returned::SEMICOLON_IF_NOTHING_RETURNED),
8585
LintId::of(stable_sort_primitive::STABLE_SORT_PRIMITIVE),
8686
LintId::of(strings::STRING_ADD_ASSIGN),
87-
LintId::of(trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS),
88-
LintId::of(trait_bounds::TYPE_REPETITION_IN_BOUNDS),
8987
LintId::of(transmute::TRANSMUTE_PTR_TO_PTR),
9088
LintId::of(types::LINKEDLIST),
9189
LintId::of(types::OPTION_OPTION),

clippy_lints/src/trait_bounds.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ declare_clippy_lint! {
3535
/// ```
3636
#[clippy::version = "1.38.0"]
3737
pub TYPE_REPETITION_IN_BOUNDS,
38-
pedantic,
38+
nursery,
3939
"Types are repeated unnecessary in trait bounds use `+` instead of using `T: _, T: _`"
4040
}
4141

@@ -65,7 +65,7 @@ declare_clippy_lint! {
6565
/// ```
6666
#[clippy::version = "1.47.0"]
6767
pub TRAIT_DUPLICATION_IN_BOUNDS,
68-
pedantic,
68+
nursery,
6969
"Check if the same trait bounds are specified twice during a function declaration"
7070
}
7171

tests/ui/trait_duplication_in_bounds.rs

+3
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,7 @@ trait FooIter: Iterator<Item = Foo> {
9595
}
9696
}
9797

98+
// This should not lint
99+
fn impl_trait(_: impl AsRef<str>, _: impl AsRef<str>) {}
100+
98101
fn main() {}

tests/ui/trait_duplication_in_bounds.stderr

+9-1
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,13 @@ LL | Self: Iterator<Item = Foo>,
6767
|
6868
= help: consider removing this trait bound
6969

70-
error: aborting due to 8 previous errors
70+
error: this trait bound is already specified in the where clause
71+
--> $DIR/trait_duplication_in_bounds.rs:99:23
72+
|
73+
LL | fn impl_trait(_: impl AsRef<str>, _: impl AsRef<str>) {}
74+
| ^^^^^^^^^^
75+
|
76+
= help: consider removing this trait bound
77+
78+
error: aborting due to 9 previous errors
7179

tests/ui/type_repetition_in_bounds.rs

+3
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,7 @@ where
7979
u: U,
8080
}
8181

82+
// This should not lint
83+
fn impl_trait(_: impl AsRef<str>, _: impl AsRef<str>) {}
84+
8285
fn main() {}

tests/ui/type_repetition_in_bounds.stderr

+9-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,13 @@ LL | Self: Copy + Default + Ord,
1919
|
2020
= help: consider combining the bounds: `Self: Clone + Copy + Default + Ord`
2121

22-
error: aborting due to 2 previous errors
22+
error: this type has already been used as a bound predicate
23+
--> $DIR/type_repetition_in_bounds.rs:83:43
24+
|
25+
LL | fn impl_trait(_: impl AsRef<str>, _: impl AsRef<str>) {}
26+
| ^^^^^^^^^^
27+
|
28+
= help: consider combining the bounds: `impl AsRef<str>: AsRef<str> + AsRef<str>`
29+
30+
error: aborting due to 3 previous errors
2331

0 commit comments

Comments
 (0)