Merge branch 'pr-260'

Conflicts:
	src/lib.rs
This commit is contained in:
Manish Goregaokar
2015-08-31 15:06:53 +05:30
4 changed files with 41 additions and 1 deletions

View File

@@ -191,3 +191,24 @@ fn is_lit_one(expr: &Expr) -> bool {
}
false
}
declare_lint!(pub REDUNDANT_PATTERN, Warn, "using `name @ _` in a pattern");
#[derive(Copy,Clone)]
pub struct PatternPass;
impl LintPass for PatternPass {
fn get_lints(&self) -> LintArray {
lint_array!(REDUNDANT_PATTERN)
}
fn check_pat(&mut self, cx: &Context, pat: &Pat) {
if let PatIdent(_, ref ident, Some(ref right)) = pat.node {
if right.node == PatWild(PatWildSingle) {
cx.span_lint(REDUNDANT_PATTERN, pat.span, &format!(
"the `{} @ _` pattern can be written as just `{}`",
ident.node.name, ident.node.name));
}
}
}
}