about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEvan Typanski <evantypanski@gmail.com>2022-10-06 15:36:28 -0400
committerEvan Typanski <evantypanski@gmail.com>2022-10-06 15:36:28 -0400
commit39164acf6e62a3ff55d6c210acc1095d9ccc95bb (patch)
tree4b7cc4091f537d39846111c52b676d61a2464e8a
parent23b16998c35674e74511bfe70a7324ca12119976 (diff)
downloadrust-39164acf6e62a3ff55d6c210acc1095d9ccc95bb.tar.gz
rust-39164acf6e62a3ff55d6c210acc1095d9ccc95bb.zip
Fix flipped variable that made it through
-rw-r--r--clippy_lints/src/matches/match_single_binding.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/clippy_lints/src/matches/match_single_binding.rs b/clippy_lints/src/matches/match_single_binding.rs
index b64c4588748..1bf8d4e96ad 100644
--- a/clippy_lints/src/matches/match_single_binding.rs
+++ b/clippy_lints/src/matches/match_single_binding.rs
@@ -58,7 +58,7 @@ pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], e
                         &snippet_body,
                         &mut applicability,
                         Some(span),
-                        false,
+                        true,
                     );
 
                     span_lint_and_sugg(
@@ -91,7 +91,7 @@ pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], e
                         &snippet_body,
                         &mut applicability,
                         None,
-                        false,
+                        true,
                     );
                     (expr.span, sugg)
                 },
@@ -116,7 +116,7 @@ pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], e
                     &snippet_body,
                     &mut applicability,
                     None,
-                    true,
+                    false,
                 );
 
                 span_lint_and_sugg(
@@ -208,13 +208,13 @@ fn sugg_with_curlies<'a>(
     });
 
     let scrutinee = if needs_var_binding {
-        snippet_with_applicability(cx, matched_vars, "..", applicability).to_string()
-    } else {
         format!(
             "let {} = {}",
             snippet_with_applicability(cx, bind_names, "..", applicability),
             snippet_with_applicability(cx, matched_vars, "..", applicability)
         )
+    } else {
+        snippet_with_applicability(cx, matched_vars, "..", applicability).to_string()
     };
 
     format!("{cbrace_start}{scrutinee};\n{indent}{assignment_str}{snippet_body}{cbrace_end}")