@@ -77,9 +77,9 @@ use rustc_hir::itemlikevisit::ItemLikeVisitor;
77
77
use rustc_hir:: LangItem :: { OptionNone , ResultErr , ResultOk } ;
78
78
use rustc_hir:: {
79
79
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 ,
83
83
} ;
84
84
use rustc_lint:: { LateContext , Level , Lint , LintContext } ;
85
85
use rustc_middle:: hir:: place:: PlaceBase ;
@@ -360,24 +360,14 @@ pub fn last_path_segment<'tcx>(path: &QPath<'tcx>) -> &'tcx PathSegment<'tcx> {
360
360
}
361
361
}
362
362
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 )
374
367
. 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 ,
381
371
} )
382
372
}
383
373
0 commit comments