@@ -8,8 +8,8 @@ use rustc_data_structures::unhash::UnhashMap;
88use rustc_errors:: Applicability ;
99use rustc_hir:: def:: Res ;
1010use 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 ,
1313} ;
1414use rustc_lint:: { LateContext , LateLintPass } ;
1515use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
@@ -95,7 +95,7 @@ declare_clippy_lint! {
9595 /// ```
9696 #[ clippy:: version = "1.62.0" ]
9797 pub REPEATED_WHERE_CLAUSE_OR_TRAIT_BOUND ,
98- pedantic ,
98+ nursery ,
9999 "Traits are repeated within trait bounds or where clause"
100100}
101101
@@ -282,27 +282,25 @@ fn check_trait_bound_duplication(cx: &LateContext<'_>, gen: &'_ Generics<'_>) {
282282}
283283
284284#[ 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+ ) ;
286290
287291fn check_bounds_or_where_duplication ( cx : & LateContext < ' _ > , gen : & ' _ Generics < ' _ > ) {
288292 if gen. span . from_expansion ( ) {
289293 return ;
290294 }
291295
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 {
300297 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) ;
306304 }
307305 }
308306}
@@ -336,10 +334,10 @@ fn try_into_comparable_bound(bound: &GenericBound<'_>) -> Option<ComparableBound
336334 } )
337335 . flatten ( )
338336 . 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(),
343341 ) )
344342 } else {
345343 None
0 commit comments