Skip to content

Commit b831257

Browse files
author
Allen Hsu
committed
Move repeated_where_clauses_or_trait_bounds into trait_duplication_in_bounds lint.
1 parent 64bd372 commit b831257

7 files changed

+60
-29
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3861,7 +3861,6 @@ Released 2018-09-13
38613861
[`ref_option_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_option_ref
38623862
[`regex_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#regex_macro
38633863
[`repeat_once`]: https://rust-lang.github.io/rust-clippy/master/index.html#repeat_once
3864-
[`repeated_where_clauses_or_trait_bounds`]: https://rust-lang.github.io/rust-clippy/master/index.html#repeated_where_clauses_or_trait_bounds
38653864
[`replace_consts`]: https://rust-lang.github.io/rust-clippy/master/index.html#replace_consts
38663865
[`rest_pat_in_fully_bound_structs`]: https://rust-lang.github.io/rust-clippy/master/index.html#rest_pat_in_fully_bound_structs
38673866
[`result_expect_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_expect_used

clippy_lints/src/lib.register_lints.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,6 @@ store.register_lints(&[
516516
temporary_assignment::TEMPORARY_ASSIGNMENT,
517517
to_digit_is_some::TO_DIGIT_IS_SOME,
518518
trailing_empty_array::TRAILING_EMPTY_ARRAY,
519-
trait_bounds::REPEATED_WHERE_CLAUSES_OR_TRAIT_BOUNDS,
520519
trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS,
521520
trait_bounds::TYPE_REPETITION_IN_BOUNDS,
522521
transmute::CROSSPOINTER_TRANSMUTE,

clippy_lints/src/lib.register_pedantic.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), vec![
8686
LintId::of(semicolon_if_nothing_returned::SEMICOLON_IF_NOTHING_RETURNED),
8787
LintId::of(stable_sort_primitive::STABLE_SORT_PRIMITIVE),
8888
LintId::of(strings::STRING_ADD_ASSIGN),
89-
LintId::of(trait_bounds::REPEATED_WHERE_CLAUSES_OR_TRAIT_BOUNDS),
9089
LintId::of(transmute::TRANSMUTE_PTR_TO_PTR),
9190
LintId::of(types::LINKEDLIST),
9291
LintId::of(types::OPTION_OPTION),

clippy_lints/src/trait_bounds.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,7 @@ declare_clippy_lint! {
6363
///
6464
/// fn func<T>(arg: T) where T: Clone + Default {}
6565
/// ```
66-
#[clippy::version = "1.47.0"]
67-
pub TRAIT_DUPLICATION_IN_BOUNDS,
68-
nursery,
69-
"check if the same trait bounds are specified twice during a function declaration"
70-
}
71-
72-
declare_clippy_lint! {
73-
/// ### What it does
74-
/// Checks for multiple instances of the same where clause or trait bound
7566
///
76-
/// ### Why is this bad?
77-
/// Adds to code noise
78-
///
79-
/// ### Example
8067
/// ```rust
8168
/// fn foo<T: Default + Default>(bar: T) {}
8269
/// ```
@@ -92,10 +79,10 @@ declare_clippy_lint! {
9279
/// ```rust
9380
/// fn foo<T>(bar: T) where T: Default {}
9481
/// ```
95-
#[clippy::version = "1.62.0"]
96-
pub REPEATED_WHERE_CLAUSES_OR_TRAIT_BOUNDS,
97-
pedantic,
98-
"traits are repeated within trait bounds or where clause"
82+
#[clippy::version = "1.47.0"]
83+
pub TRAIT_DUPLICATION_IN_BOUNDS,
84+
nursery,
85+
"check if the same trait bounds are specified twice during a function declaration"
9986
}
10087

10188
#[derive(Copy, Clone)]
@@ -110,7 +97,7 @@ impl TraitBounds {
11097
}
11198
}
11299

113-
impl_lint_pass!(TraitBounds => [TYPE_REPETITION_IN_BOUNDS, TRAIT_DUPLICATION_IN_BOUNDS, REPEATED_WHERE_CLAUSES_OR_TRAIT_BOUNDS]);
100+
impl_lint_pass!(TraitBounds => [TYPE_REPETITION_IN_BOUNDS, TRAIT_DUPLICATION_IN_BOUNDS]);
114101

115102
impl<'tcx> LateLintPass<'tcx> for TraitBounds {
116103
fn check_generics(&mut self, cx: &LateContext<'tcx>, gen: &'tcx Generics<'_>) {
@@ -374,7 +361,7 @@ fn rollup_traits(cx: &LateContext<'_>, bounds: &[GenericBound<'_>], msg: &str) {
374361

375362
span_lint_and_sugg(
376363
cx,
377-
REPEATED_WHERE_CLAUSES_OR_TRAIT_BOUNDS,
364+
TRAIT_DUPLICATION_IN_BOUNDS,
378365
all_trait_span,
379366
msg,
380367
"try",

tests/ui/repeated_where_clauses_or_trait_bounds.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-rustfix
22
//
33
#![allow(unused)]
4-
#![deny(clippy::repeated_where_clauses_or_trait_bounds)]
4+
#![deny(clippy::trait_duplication_in_bounds)]
55

66
fn bad_foo<T: Clone + Copy, U: Clone + Copy>(arg0: T, argo1: U) {
77
unimplemented!();

tests/ui/repeated_where_clauses_or_trait_bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-rustfix
22
//
33
#![allow(unused)]
4-
#![deny(clippy::repeated_where_clauses_or_trait_bounds)]
4+
#![deny(clippy::trait_duplication_in_bounds)]
55

66
fn bad_foo<T: Clone + Clone + Clone + Copy, U: Clone + Copy>(arg0: T, argo1: U) {
77
unimplemented!();

tests/ui/repeated_where_clauses_or_trait_bounds.stderr

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
1-
error: these bounds contain repeated elements
1+
error: this trait bound is already specified in the where clause
22
--> $DIR/repeated_where_clauses_or_trait_bounds.rs:6:15
33
|
44
LL | fn bad_foo<T: Clone + Clone + Clone + Copy, U: Clone + Copy>(arg0: T, argo1: U) {
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy`
5+
| ^^^^^
66
|
77
note: the lint level is defined here
88
--> $DIR/repeated_where_clauses_or_trait_bounds.rs:4:9
99
|
10-
LL | #![deny(clippy::repeated_where_clauses_or_trait_bounds)]
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(clippy::trait_duplication_in_bounds)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
= help: consider removing this trait bound
13+
14+
error: these bounds contain repeated elements
15+
--> $DIR/repeated_where_clauses_or_trait_bounds.rs:6:15
16+
|
17+
LL | fn bad_foo<T: Clone + Clone + Clone + Copy, U: Clone + Copy>(arg0: T, argo1: U) {
18+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy`
19+
20+
error: this trait bound is already specified in the where clause
21+
--> $DIR/repeated_where_clauses_or_trait_bounds.rs:12:8
22+
|
23+
LL | T: Clone + Clone + Clone + Copy,
24+
| ^^^^^
25+
|
26+
= help: consider removing this trait bound
1227

1328
error: these where clauses contain repeated elements
1429
--> $DIR/repeated_where_clauses_or_trait_bounds.rs:12:8
@@ -28,6 +43,14 @@ error: these where clauses contain repeated elements
2843
LL | Self: Clone + Clone + Clone;
2944
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone`
3045

46+
error: this trait bound is already specified in the where clause
47+
--> $DIR/repeated_where_clauses_or_trait_bounds.rs:61:24
48+
|
49+
LL | trait BadTraitBound<T: Clone + Clone + Clone + Copy, U: Clone + Copy> {
50+
| ^^^^^
51+
|
52+
= help: consider removing this trait bound
53+
3154
error: these bounds contain repeated elements
3255
--> $DIR/repeated_where_clauses_or_trait_bounds.rs:61:24
3356
|
@@ -40,17 +63,41 @@ error: these where clauses contain repeated elements
4063
LL | T: Clone + Clone + Clone + Copy,
4164
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy`
4265

66+
error: this trait bound is already specified in the where clause
67+
--> $DIR/repeated_where_clauses_or_trait_bounds.rs:97:20
68+
|
69+
LL | fn good_generic<T: GenericTrait<u64> + GenericTrait<u32>>(arg0: T) {
70+
| ^^^^^^^^^^^^^^^^^
71+
|
72+
= help: consider removing this trait bound
73+
74+
error: this trait bound is already specified in the where clause
75+
--> $DIR/repeated_where_clauses_or_trait_bounds.rs:101:19
76+
|
77+
LL | fn bad_generic<T: GenericTrait<u64> + GenericTrait<u32> + GenericTrait<u64>>(arg0: T) {
78+
| ^^^^^^^^^^^^^^^^^
79+
|
80+
= help: consider removing this trait bound
81+
4382
error: these bounds contain repeated elements
4483
--> $DIR/repeated_where_clauses_or_trait_bounds.rs:101:19
4584
|
4685
LL | fn bad_generic<T: GenericTrait<u64> + GenericTrait<u32> + GenericTrait<u64>>(arg0: T) {
4786
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `GenericTrait<u32> + GenericTrait<u64>`
4887

88+
error: this trait bound is already specified in the where clause
89+
--> $DIR/repeated_where_clauses_or_trait_bounds.rs:109:22
90+
|
91+
LL | fn qualified_path<T: std::clone::Clone + Clone + foo::Clone>(arg0: T) {
92+
| ^^^^^^^^^^^^^^^^^
93+
|
94+
= help: consider removing this trait bound
95+
4996
error: these bounds contain repeated elements
5097
--> $DIR/repeated_where_clauses_or_trait_bounds.rs:109:22
5198
|
5299
LL | fn qualified_path<T: std::clone::Clone + Clone + foo::Clone>(arg0: T) {
53100
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + foo::Clone`
54101

55-
error: aborting due to 8 previous errors
102+
error: aborting due to 14 previous errors
56103

0 commit comments

Comments
 (0)