mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 23:20:39 +00:00
don't lint similar_names inside #[test] functions
This commit is contained in:
parent
469b3d51b4
commit
10f468e679
1 changed files with 19 additions and 14 deletions
|
@ -2,7 +2,8 @@ use rustc::lint::*;
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use syntax::parse::token::InternedString;
|
use syntax::parse::token::InternedString;
|
||||||
use syntax::ast::*;
|
use syntax::ast::*;
|
||||||
use syntax::visit::{self, FnKind};
|
use syntax::attr;
|
||||||
|
use syntax::visit;
|
||||||
use utils::{span_lint_and_then, in_macro, span_lint};
|
use utils::{span_lint_and_then, in_macro, span_lint};
|
||||||
|
|
||||||
/// **What it does:** This lint warns about names that are very similar and thus confusing
|
/// **What it does:** This lint warns about names that are very similar and thus confusing
|
||||||
|
@ -237,24 +238,28 @@ impl<'v, 'a, 'b> visit::Visitor<'v> for SimilarNamesLocalVisitor<'a, 'b> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
fn visit_item(&mut self, _: &'v Item) {
|
fn visit_item(&mut self, _: &'v Item) {
|
||||||
// do nothing
|
// do not recurse into inner items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EarlyLintPass for NonExpressiveNames {
|
impl EarlyLintPass for NonExpressiveNames {
|
||||||
fn check_fn(&mut self, cx: &EarlyContext, _: FnKind, decl: &FnDecl, blk: &Block, _: Span, _: NodeId) {
|
fn check_item(&mut self, cx: &EarlyContext, item: &Item) {
|
||||||
let mut visitor = SimilarNamesLocalVisitor {
|
if let ItemKind::Fn(ref decl, _, _, _, _, ref blk) = item.node {
|
||||||
names: Vec::new(),
|
if !attr::contains_name(&item.attrs, "test") {
|
||||||
cx: cx,
|
let mut visitor = SimilarNamesLocalVisitor {
|
||||||
lint: &self,
|
names: Vec::new(),
|
||||||
single_char_names: Vec::new(),
|
cx: cx,
|
||||||
};
|
lint: &self,
|
||||||
// initialize with function arguments
|
single_char_names: Vec::new(),
|
||||||
for arg in &decl.inputs {
|
};
|
||||||
visit::walk_pat(&mut SimilarNamesNameVisitor(&mut visitor), &arg.pat);
|
// initialize with function arguments
|
||||||
|
for arg in &decl.inputs {
|
||||||
|
visit::walk_pat(&mut SimilarNamesNameVisitor(&mut visitor), &arg.pat);
|
||||||
|
}
|
||||||
|
// walk all other bindings
|
||||||
|
visit::walk_block(&mut visitor, blk);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// walk all other bindings
|
|
||||||
visit::walk_block(&mut visitor, blk);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue