@@ -128,7 +128,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
128128
129129 fn check_impl_item ( & mut self , cx : & LateContext < ' tcx > , item : & ' tcx ImplItem < ' _ > ) {
130130 if_chain ! {
131- if item. ident. as_str ( ) == " len" ;
131+ if item. ident. name == sym :: len;
132132 if let ImplItemKind :: Fn ( sig, _) = & item. kind;
133133 if sig. decl. implicit_self. has_implicit_self( ) ;
134134 if cx. access_levels. is_exported( item. hir_id( ) ) ;
@@ -189,8 +189,8 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
189189}
190190
191191fn check_trait_items ( cx : & LateContext < ' _ > , visited_trait : & Item < ' _ > , trait_items : & [ TraitItemRef ] ) {
192- fn is_named_self ( cx : & LateContext < ' _ > , item : & TraitItemRef , name : & str ) -> bool {
193- item. ident . name . as_str ( ) == name
192+ fn is_named_self ( cx : & LateContext < ' _ > , item : & TraitItemRef , name : Symbol ) -> bool {
193+ item. ident . name == name
194194 && if let AssocItemKind :: Fn { has_self } = item. kind {
195195 has_self && { cx. tcx . fn_sig ( item. id . def_id ) . inputs ( ) . skip_binder ( ) . len ( ) == 1 }
196196 } else {
@@ -207,7 +207,9 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items
207207 }
208208 }
209209
210- if cx. access_levels . is_exported ( visited_trait. hir_id ( ) ) && trait_items. iter ( ) . any ( |i| is_named_self ( cx, i, "len" ) ) {
210+ if cx. access_levels . is_exported ( visited_trait. hir_id ( ) )
211+ && trait_items. iter ( ) . any ( |i| is_named_self ( cx, i, sym:: len) )
212+ {
211213 let mut current_and_super_traits = DefIdSet :: default ( ) ;
212214 fill_trait_set ( visited_trait. def_id . to_def_id ( ) , & mut current_and_super_traits, cx) ;
213215
@@ -401,7 +403,7 @@ fn check_len(
401403 return ;
402404 }
403405
404- if method_name. as_str ( ) == " len" && args. len ( ) == 1 && has_is_empty ( cx, & args[ 0 ] ) {
406+ if method_name == sym :: len && args. len ( ) == 1 && has_is_empty ( cx, & args[ 0 ] ) {
405407 let mut applicability = Applicability :: MachineApplicable ;
406408 span_lint_and_sugg (
407409 cx,
0 commit comments