Skip to content

Duplicate warnings for match_bool / single_match #403 #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 0 additions & 2 deletions tests/compile-fail/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!"); },
_ => (),
};
Expand Down