@@ -8,8 +8,8 @@ use rustc_data_structures::unhash::UnhashMap;
8
8
use rustc_errors:: Applicability ;
9
9
use rustc_hir:: def:: Res ;
10
10
use rustc_hir:: {
11
- GenericArg , GenericBound , GenericBound , Generics , Item , ItemKind , Node , ParamName , Path , PathSegment , QPath ,
12
- TraitItem , Ty , TyKind , WherePredicate ,
11
+ GenericArg , GenericBound , Generics , Item , ItemKind , Node , Path , PathSegment , QPath , TraitItem , Ty , TyKind ,
12
+ WherePredicate ,
13
13
} ;
14
14
use rustc_lint:: { LateContext , LateLintPass } ;
15
15
use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
@@ -95,7 +95,7 @@ declare_clippy_lint! {
95
95
/// ```
96
96
#[ clippy:: version = "1.62.0" ]
97
97
pub REPEATED_WHERE_CLAUSE_OR_TRAIT_BOUND ,
98
- pedantic ,
98
+ nursery ,
99
99
"Traits are repeated within trait bounds or where clause"
100
100
}
101
101
@@ -282,27 +282,25 @@ fn check_trait_bound_duplication(cx: &LateContext<'_>, gen: &'_ Generics<'_>) {
282
282
}
283
283
284
284
#[ derive( PartialEq , Eq , Hash , Debug ) ]
285
- struct ComparableBound ( Res , Vec < Res > , Vec < ComparableBound > ) ;
285
+ struct ComparableBound (
286
+ Res ,
287
+ Vec < Res > ,
288
+ // Vec<ComparableBound>
289
+ ) ;
286
290
287
291
fn check_bounds_or_where_duplication ( cx : & LateContext < ' _ > , gen : & ' _ Generics < ' _ > ) {
288
292
if gen. span . from_expansion ( ) {
289
293
return ;
290
294
}
291
295
292
- for param in gen. params {
293
- if let ParamName :: Plain ( _) = param. name {
294
- // other alternatives are errors and elided which won't have duplicates
295
- rollup_traits ( cx, param. bounds , "this trait bound contains repeated elements" ) ;
296
- }
297
- }
298
-
299
- for predicate in gen. where_clause . predicates {
296
+ for predicate in gen. predicates {
300
297
if let WherePredicate :: BoundPredicate ( ref bound_predicate) = predicate {
301
- rollup_traits (
302
- cx,
303
- bound_predicate. bounds ,
304
- "this where clause contains repeated elements" ,
305
- ) ;
298
+ let msg = if predicate. in_where_clause ( ) {
299
+ "these where clauses contain repeated elements"
300
+ } else {
301
+ "these bounds contain repeated elements"
302
+ } ;
303
+ rollup_traits ( cx, bound_predicate. bounds , msg) ;
306
304
}
307
305
}
308
306
}
@@ -336,10 +334,10 @@ fn try_into_comparable_bound(bound: &GenericBound<'_>) -> Option<ComparableBound
336
334
} )
337
335
. flatten ( )
338
336
. collect ( ) ,
339
- t. bound_generic_params
340
- . iter ( )
341
- . flat_map ( |param| param. bounds . iter ( ) . filter_map ( try_into_comparable_bound) )
342
- . collect ( ) ,
337
+ // t.bound_generic_params
338
+ // .iter()
339
+ // .flat_map(|param| param.bounds.iter().filter_map(try_into_comparable_bound))
340
+ // .collect(),
343
341
) )
344
342
} else {
345
343
None
0 commit comments