Skip to content

Commit

Permalink
HACK: Move buggy lints to nursery
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
flip1995 committed May 5, 2022
1 parent 7e017db commit bb01aca
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 6 deletions.
2 changes: 2 additions & 0 deletions clippy_lints/src/lib.register_nursery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
LintId::of(strings::STRING_LIT_AS_BYTES),
LintId::of(suspicious_operation_groupings::SUSPICIOUS_OPERATION_GROUPINGS),
LintId::of(trailing_empty_array::TRAILING_EMPTY_ARRAY),
LintId::of(trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS),
LintId::of(trait_bounds::TYPE_REPETITION_IN_BOUNDS),
LintId::of(transmute::TRANSMUTE_UNDEFINED_REPR),
LintId::of(transmute::USELESS_TRANSMUTE),
LintId::of(use_self::USE_SELF),
Expand Down
2 changes: 0 additions & 2 deletions clippy_lints/src/lib.register_pedantic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), vec![
LintId::of(semicolon_if_nothing_returned::SEMICOLON_IF_NOTHING_RETURNED),
LintId::of(stable_sort_primitive::STABLE_SORT_PRIMITIVE),
LintId::of(strings::STRING_ADD_ASSIGN),
LintId::of(trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS),
LintId::of(trait_bounds::TYPE_REPETITION_IN_BOUNDS),
LintId::of(transmute::TRANSMUTE_PTR_TO_PTR),
LintId::of(types::LINKEDLIST),
LintId::of(types::OPTION_OPTION),
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/trait_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ declare_clippy_lint! {
/// ```
#[clippy::version = "1.38.0"]
pub TYPE_REPETITION_IN_BOUNDS,
pedantic,
nursery,
"Types are repeated unnecessary in trait bounds use `+` instead of using `T: _, T: _`"
}

Expand Down Expand Up @@ -65,7 +65,7 @@ declare_clippy_lint! {
/// ```
#[clippy::version = "1.47.0"]
pub TRAIT_DUPLICATION_IN_BOUNDS,
pedantic,
nursery,
"Check if the same trait bounds are specified twice during a function declaration"
}

Expand Down
3 changes: 3 additions & 0 deletions tests/ui/trait_duplication_in_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,7 @@ trait FooIter: Iterator<Item = Foo> {
}
}

// This should not lint
fn impl_trait(_: impl AsRef<str>, _: impl AsRef<str>) {}

fn main() {}
10 changes: 9 additions & 1 deletion tests/ui/trait_duplication_in_bounds.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,13 @@ LL | Self: Iterator<Item = Foo>,
|
= help: consider removing this trait bound

error: aborting due to 8 previous errors
error: this trait bound is already specified in the where clause
--> $DIR/trait_duplication_in_bounds.rs:99:23
|
LL | fn impl_trait(_: impl AsRef<str>, _: impl AsRef<str>) {}
| ^^^^^^^^^^
|
= help: consider removing this trait bound

error: aborting due to 9 previous errors

3 changes: 3 additions & 0 deletions tests/ui/type_repetition_in_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,7 @@ where
u: U,
}

// This should not lint
fn impl_trait(_: impl AsRef<str>, _: impl AsRef<str>) {}

fn main() {}
10 changes: 9 additions & 1 deletion tests/ui/type_repetition_in_bounds.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,13 @@ LL | Self: Copy + Default + Ord,
|
= help: consider combining the bounds: `Self: Clone + Copy + Default + Ord`

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

error: aborting due to 3 previous errors

0 comments on commit bb01aca

Please sign in to comment.