@@ -2,7 +2,10 @@ use clippy_utils::diagnostics::span_lint_and_then;
22use clippy_utils:: source:: snippet;
33use rustc_errors:: { Applicability , SuggestionStyle } ;
44use rustc_hir:: def_id:: DefId ;
5- use rustc_hir:: { GenericArg , GenericBound , GenericBounds , ItemKind , TraitBoundModifier , TyKind , TypeBinding } ;
5+ use rustc_hir:: {
6+ GenericArg , GenericBound , GenericBounds , ItemKind , PredicateOrigin , TraitBoundModifier , TyKind , TypeBinding ,
7+ WherePredicate ,
8+ } ;
69use rustc_hir_analysis:: hir_ty_to_ty;
710use rustc_lint:: { LateContext , LateLintPass } ;
811use rustc_middle:: ty:: { self , ClauseKind , Generics , Ty , TyCtxt } ;
@@ -326,6 +329,19 @@ fn check<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds<'tcx>) {
326329}
327330
328331impl < ' tcx > LateLintPass < ' tcx > for ImpliedBoundsInImpls {
332+ fn check_generics ( & mut self , cx : & LateContext < ' tcx > , generics : & rustc_hir:: Generics < ' tcx > ) {
333+ for predicate in generics. predicates {
334+ if let WherePredicate :: BoundPredicate ( predicate) = predicate
335+ // In theory, the origin doesn't really matter,
336+ // we *could* also lint on explicit where clauses written out by the user,
337+ // not just impl trait desugared ones, but that contradicts with the lint name...
338+ && let PredicateOrigin :: ImplTrait = predicate. origin
339+ {
340+ check ( cx, predicate. bounds ) ;
341+ }
342+ }
343+ }
344+
329345 fn check_ty ( & mut self , cx : & LateContext < ' _ > , ty : & rustc_hir:: Ty < ' _ > ) {
330346 if let TyKind :: OpaqueDef ( item_id, ..) = ty. kind
331347 && let item = cx. tcx . hir ( ) . item ( item_id)
0 commit comments