From 8e4c2171d24a3f43a5f6d7af3c15efb6d1d56803 Mon Sep 17 00:00:00 2001 From: wartman4404 Date: Wed, 28 Oct 2015 22:26:48 -0500 Subject: [PATCH] Don't show single_match if match_bool also applies --- src/matches.rs | 6 ++++-- tests/compile-fail/matches.rs | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/matches.rs b/src/matches.rs index a7cfefd7af5..fb000c24364 100644 --- a/src/matches.rs +++ b/src/matches.rs @@ -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 \ diff --git a/tests/compile-fail/matches.rs b/tests/compile-fail/matches.rs index f0cc650f753..ff92a67271b 100755 --- a/tests/compile-fail/matches.rs +++ b/tests/compile-fail/matches.rs @@ -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!"); }, _ => (), };