@@ -4,7 +4,7 @@ use rustc_hir::def_id::LocalDefId;
4
4
use rustc_hir:: { FnSig , ImplItem , ImplItemKind , Item , ItemKind , Node , TraitItem , TraitItemKind } ;
5
5
use rustc_lint:: { LateContext , LateLintPass } ;
6
6
use rustc_session:: declare_lint_pass;
7
- use rustc_span:: symbol :: sym;
7
+ use rustc_span:: { sym, Symbol } ;
8
8
9
9
declare_clippy_lint ! {
10
10
/// ### What it does
@@ -43,30 +43,27 @@ declare_lint_pass!(IterNotReturningIterator => [ITER_NOT_RETURNING_ITERATOR]);
43
43
44
44
impl < ' tcx > LateLintPass < ' tcx > for IterNotReturningIterator {
45
45
fn check_trait_item ( & mut self , cx : & LateContext < ' tcx > , item : & ' tcx TraitItem < ' _ > ) {
46
- let name = item. ident . name . as_str ( ) ;
47
- if matches ! ( name, "iter" | "iter_mut" ) {
48
- if let TraitItemKind :: Fn ( fn_sig, _) = & item. kind {
49
- check_sig ( cx, name, fn_sig, item. owner_id . def_id ) ;
50
- }
46
+ if let TraitItemKind :: Fn ( fn_sig, _) = & item. kind
47
+ && matches ! ( item. ident. name, sym:: iter | sym:: iter_mut)
48
+ {
49
+ check_sig ( cx, item. ident . name , fn_sig, item. owner_id . def_id ) ;
51
50
}
52
51
}
53
52
54
53
fn check_impl_item ( & mut self , cx : & LateContext < ' tcx > , item : & ' tcx ImplItem < ' tcx > ) {
55
- let name = item. ident . name . as_str ( ) ;
56
- if matches ! ( name, " iter" | " iter_mut" )
54
+ if let ImplItemKind :: Fn ( fn_sig , _ ) = & item. kind
55
+ && matches ! ( item . ident . name, sym :: iter | sym :: iter_mut)
57
56
&& !matches ! (
58
57
cx. tcx. parent_hir_node( item. hir_id( ) ) ,
59
58
Node :: Item ( Item { kind: ItemKind :: Impl ( i) , .. } ) if i. of_trait. is_some( )
60
59
)
61
60
{
62
- if let ImplItemKind :: Fn ( fn_sig, _) = & item. kind {
63
- check_sig ( cx, name, fn_sig, item. owner_id . def_id ) ;
64
- }
61
+ check_sig ( cx, item. ident . name , fn_sig, item. owner_id . def_id ) ;
65
62
}
66
63
}
67
64
}
68
65
69
- fn check_sig ( cx : & LateContext < ' _ > , name : & str , sig : & FnSig < ' _ > , fn_id : LocalDefId ) {
66
+ fn check_sig ( cx : & LateContext < ' _ > , name : Symbol , sig : & FnSig < ' _ > , fn_id : LocalDefId ) {
70
67
if sig. decl . implicit_self . has_implicit_self ( ) {
71
68
let ret_ty = cx
72
69
. tcx
0 commit comments