@@ -6,11 +6,12 @@ use rustc_hir::intravisit::{
66 walk_fn_decl, walk_generic_param, walk_generics, walk_impl_item_ref, walk_item, walk_param_bound,
77 walk_poly_trait_ref, walk_trait_ref, walk_ty, Visitor ,
88} ;
9+ use rustc_hir:: lang_items;
910use rustc_hir:: FnRetTy :: Return ;
1011use rustc_hir:: {
1112 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 ,
1415} ;
1516use rustc_lint:: { LateContext , LateLintPass } ;
1617use rustc_middle:: hir:: nested_filter as middle_nested_filter;
@@ -364,8 +365,6 @@ fn unique_lifetimes(lts: &[RefLt]) -> usize {
364365 lts. iter ( ) . collect :: < FxHashSet < _ > > ( ) . len ( )
365366}
366367
367- const CLOSURE_TRAIT_BOUNDS : [ LangItem ; 3 ] = [ LangItem :: Fn , LangItem :: FnMut , LangItem :: FnOnce ] ;
368-
369368/// A visitor usable for `rustc_front::visit::walk_ty()`.
370369struct RefVisitor < ' a , ' tcx > {
371370 cx : & ' a LateContext < ' tcx > ,
@@ -424,12 +423,8 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
424423
425424 fn visit_poly_trait_ref ( & mut self , poly_tref : & ' tcx PolyTraitRef < ' tcx > ) {
426425 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)
433428 } ) {
434429 let mut sub_visitor = RefVisitor :: new ( self . cx ) ;
435430 sub_visitor. visit_trait_ref ( trait_ref) ;
0 commit comments