@@ -77,9 +77,9 @@ use rustc_hir::itemlikevisit::ItemLikeVisitor;
7777use rustc_hir:: LangItem :: { OptionNone , ResultErr , ResultOk } ;
7878use rustc_hir:: {
7979 def, lang_items, Arm , ArrayLen , BindingAnnotation , Block , BlockCheckMode , Body , Constness , Destination , Expr ,
80- ExprKind , FnDecl , ForeignItem , GenericArgs , HirId , Impl , ImplItem , ImplItemKind , IsAsync , Item , ItemKind , LangItem ,
81- Local , MatchSource , Mutability , Node , Param , Pat , PatKind , Path , PathSegment , PrimTy , QPath , Stmt , StmtKind ,
82- Target , TraitItem , TraitItemKind , TraitRef , TyKind , UnOp ,
80+ ExprKind , FnDecl , ForeignItem , HirId , Impl , ImplItem , ImplItemKind , IsAsync , Item , ItemKind , LangItem , Local ,
81+ MatchSource , Mutability , Node , Param , Pat , PatKind , Path , PathSegment , PrimTy , QPath , Stmt , StmtKind , Target ,
82+ TraitItem , TraitItemKind , TraitRef , TyKind , UnOp ,
8383} ;
8484use rustc_lint:: { LateContext , Level , Lint , LintContext } ;
8585use rustc_middle:: hir:: place:: PlaceBase ;
@@ -360,24 +360,14 @@ pub fn last_path_segment<'tcx>(path: &QPath<'tcx>) -> &'tcx PathSegment<'tcx> {
360360 }
361361}
362362
363- pub fn get_qpath_generics < ' tcx > ( path : & QPath < ' tcx > ) -> Option < & ' tcx GenericArgs < ' tcx > > {
364- match path {
365- QPath :: Resolved ( _, p) => p. segments . last ( ) . and_then ( |s| s. args ) ,
366- QPath :: TypeRelative ( _, s) => s. args ,
367- QPath :: LangItem ( ..) => None ,
368- }
369- }
370-
371- pub fn qpath_generic_tys < ' tcx > ( path : & QPath < ' tcx > ) -> impl Iterator < Item = & ' tcx hir:: Ty < ' tcx > > {
372- get_qpath_generics ( path)
373- . map_or ( [ ] . as_ref ( ) , |a| a. args )
363+ pub fn qpath_generic_tys < ' tcx > ( qpath : & QPath < ' tcx > ) -> impl Iterator < Item = & ' tcx hir:: Ty < ' tcx > > {
364+ last_path_segment ( qpath)
365+ . args
366+ . map_or ( & [ ] [ ..] , |a| a. args )
374367 . iter ( )
375- . filter_map ( |a| {
376- if let hir:: GenericArg :: Type ( ty) = a {
377- Some ( ty)
378- } else {
379- None
380- }
368+ . filter_map ( |a| match a {
369+ hir:: GenericArg :: Type ( ty) => Some ( ty) ,
370+ _ => None ,
381371 } )
382372}
383373
0 commit comments