@@ -6,11 +6,12 @@ use rustc_hir::intravisit::{
6
6
walk_fn_decl, walk_generic_param, walk_generics, walk_impl_item_ref, walk_item, walk_param_bound,
7
7
walk_poly_trait_ref, walk_trait_ref, walk_ty, Visitor ,
8
8
} ;
9
+ use rustc_hir:: lang_items;
9
10
use rustc_hir:: FnRetTy :: Return ;
10
11
use rustc_hir:: {
11
12
BareFnTy , BodyId , FnDecl , GenericArg , GenericBound , GenericParam , GenericParamKind , Generics , Impl , ImplItem ,
12
- ImplItemKind , Item , ItemKind , LangItem , Lifetime , LifetimeName , ParamName , PolyTraitRef , PredicateOrigin , TraitFn ,
13
- TraitItem , TraitItemKind , Ty , TyKind , WherePredicate ,
13
+ ImplItemKind , Item , ItemKind , Lifetime , LifetimeName , ParamName , PolyTraitRef , PredicateOrigin , TraitFn , TraitItem ,
14
+ TraitItemKind , Ty , TyKind , WherePredicate ,
14
15
} ;
15
16
use rustc_lint:: { LateContext , LateLintPass } ;
16
17
use rustc_middle:: hir:: nested_filter as middle_nested_filter;
@@ -364,8 +365,6 @@ fn unique_lifetimes(lts: &[RefLt]) -> usize {
364
365
lts. iter ( ) . collect :: < FxHashSet < _ > > ( ) . len ( )
365
366
}
366
367
367
- const CLOSURE_TRAIT_BOUNDS : [ LangItem ; 3 ] = [ LangItem :: Fn , LangItem :: FnMut , LangItem :: FnOnce ] ;
368
-
369
368
/// A visitor usable for `rustc_front::visit::walk_ty()`.
370
369
struct RefVisitor < ' a , ' tcx > {
371
370
cx : & ' a LateContext < ' tcx > ,
@@ -424,12 +423,8 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
424
423
425
424
fn visit_poly_trait_ref ( & mut self , poly_tref : & ' tcx PolyTraitRef < ' tcx > ) {
426
425
let trait_ref = & poly_tref. trait_ref ;
427
- if CLOSURE_TRAIT_BOUNDS . iter ( ) . any ( |& item| {
428
- self . cx
429
- . tcx
430
- . lang_items ( )
431
- . require ( item)
432
- . map_or ( false , |id| Some ( id) == trait_ref. trait_def_id ( ) )
426
+ if let Some ( id) = trait_ref. trait_def_id ( ) && lang_items:: FN_TRAITS . iter ( ) . any ( |& item| {
427
+ self . cx . tcx . lang_items ( ) . get ( item) == Some ( id)
433
428
} ) {
434
429
let mut sub_visitor = RefVisitor :: new ( self . cx ) ;
435
430
sub_visitor. visit_trait_ref ( trait_ref) ;
0 commit comments