@@ -128,7 +128,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
128
128
129
129
fn check_impl_item ( & mut self , cx : & LateContext < ' tcx > , item : & ' tcx ImplItem < ' _ > ) {
130
130
if_chain ! {
131
- if item. ident. as_str ( ) == " len" ;
131
+ if item. ident. name == sym :: len;
132
132
if let ImplItemKind :: Fn ( sig, _) = & item. kind;
133
133
if sig. decl. implicit_self. has_implicit_self( ) ;
134
134
if cx. access_levels. is_exported( item. hir_id( ) ) ;
@@ -189,8 +189,8 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
189
189
}
190
190
191
191
fn 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
194
194
&& if let AssocItemKind :: Fn { has_self } = item. kind {
195
195
has_self && { cx. tcx . fn_sig ( item. id . def_id ) . inputs ( ) . skip_binder ( ) . len ( ) == 1 }
196
196
} else {
@@ -207,7 +207,9 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items
207
207
}
208
208
}
209
209
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
+ {
211
213
let mut current_and_super_traits = DefIdSet :: default ( ) ;
212
214
fill_trait_set ( visited_trait. def_id . to_def_id ( ) , & mut current_and_super_traits, cx) ;
213
215
@@ -401,7 +403,7 @@ fn check_len(
401
403
return ;
402
404
}
403
405
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 ] ) {
405
407
let mut applicability = Applicability :: MachineApplicable ;
406
408
span_lint_and_sugg (
407
409
cx,
0 commit comments