Don't show single_match if match_bool also applies

This commit is contained in:
wartman4404 2015-10-28 22:26:48 -05:00
parent aee42f70f3
commit 8e4c2171d2
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!"); },
_ => (),
};