@@ -2,7 +2,10 @@ use clippy_utils::diagnostics::span_lint_and_then;
2
2
use clippy_utils:: source:: snippet;
3
3
use rustc_errors:: { Applicability , SuggestionStyle } ;
4
4
use 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
+ } ;
6
9
use rustc_hir_analysis:: hir_ty_to_ty;
7
10
use rustc_lint:: { LateContext , LateLintPass } ;
8
11
use rustc_middle:: ty:: { self , ClauseKind , Generics , Ty , TyCtxt } ;
@@ -326,6 +329,19 @@ fn check<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds<'tcx>) {
326
329
}
327
330
328
331
impl < ' 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
+
329
345
fn check_ty ( & mut self , cx : & LateContext < ' _ > , ty : & rustc_hir:: Ty < ' _ > ) {
330
346
if let TyKind :: OpaqueDef ( item_id, ..) = ty. kind
331
347
&& let item = cx. tcx . hir ( ) . item ( item_id)
0 commit comments