]> git.lizzy.rs Git - rust.git/commitdiff
Don't show single_match if match_bool also applies
authorwartman4404 <wartman4404@my.mstc.edu>
Thu, 29 Oct 2015 03:26:48 +0000 (22:26 -0500)
committerwartman4404 <wartman4404@my.mstc.edu>
Thu, 29 Oct 2015 03:26:48 +0000 (22:26 -0500)
src/matches.rs
tests/compile-fail/matches.rs

index a7cfefd7af5bad715c84f8b8532dced72866bb88..fb000c24364bf1d6499479b39f08d1853025b305 100644 (file)
@@ -39,8 +39,10 @@ fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
                 // 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 \
index f0cc650f7535caabd34d6efaac728e7a9fd19d68..ff92a67271b0aa6d970105a6c4ceffe1c08cc63f 100755 (executable)
@@ -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!"); },
         _ => (),
     };