- fn check_item(&mut self, cx: &EarlyContext, item: &Item) {
- if let ItemKind::Fn(ref decl, _, _, _, _, ref blk) = item.node {
- if !attr::contains_name(&item.attrs, "test") {
- let mut visitor = SimilarNamesLocalVisitor {
- names: Vec::new(),
- cx: cx,
- lint: self,
- single_char_names: Vec::new(),
- };
- // initialize with function arguments
- for arg in &decl.inputs {
- SimilarNamesNameVisitor(&mut visitor).visit_pat(&arg.pat);
- }
- // walk all other bindings
- walk_block(&mut visitor, blk);
- }
+ fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
+ if let ItemKind::Fn(ref decl, _, _, ref blk) = item.node {
+ do_check(self, cx, &item.attrs, decl, blk);
+ }
+ }
+
+ fn check_impl_item(&mut self, cx: &EarlyContext<'_>, item: &ImplItem) {
+ if let ImplItemKind::Method(ref sig, ref blk) = item.node {
+ do_check(self, cx, &item.attrs, &sig.decl, blk);
+ }
+ }
+}
+
+fn do_check(lint: &mut NonExpressiveNames, cx: &EarlyContext<'_>, attrs: &[Attribute], decl: &FnDecl, blk: &Block) {
+ if !attr::contains_name(attrs, "test") {
+ let mut visitor = SimilarNamesLocalVisitor {
+ names: Vec::new(),
+ cx,
+ lint,
+ single_char_names: Vec::new(),
+ };
+ // initialize with function arguments
+ for arg in &decl.inputs {
+ SimilarNamesNameVisitor(&mut visitor).visit_pat(&arg.pat);