Merge pull request #423 from wartman4404/master

Duplicate warnings for match_bool / single_match #403
This commit is contained in:
Manish Goregaokar 2015-10-29 09:02:56 +05:30
commit be2b1da3ef
2 changed files with 4 additions and 4 deletions

View File

@ -39,8 +39,10 @@ impl LateLintPass for MatchPass {
// but in some cases, an explicit match is preferred to catch situations
// when an enum is extended, so we don't consider these cases
arms[1].pats[0].node == PatWild(PatWildSingle) &&
// finally, we don't want any content in the second arm (unit or empty block)
is_unit_expr(&arms[1].body)
// we don't want any content in the second arm (unit or empty block)
is_unit_expr(&arms[1].body) &&
// finally, MATCH_BOOL doesn't apply here
(cx.tcx.expr_ty(ex).sty != ty::TyBool || cx.current_level(MATCH_BOOL) == Allow)
{
span_help_and_lint(cx, SINGLE_MATCH, expr.span,
"you seem to be trying to use match for destructuring a \

View File

@ -58,8 +58,6 @@ fn match_bool() {
};
match test { //~ ERROR you seem to be trying to match on a boolean expression
//~^ERROR you seem to be trying to use match
//TODO: Remove duplicate warning
false => { println!("Noooo!"); },
_ => (),
};