]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_lints/src/option_if_let_else.rs
Rollup merge of #104901 - krtab:filetype_compare, r=the8472
[rust.git] / src / tools / clippy / clippy_lints / src / option_if_let_else.rs
index 4eb42da1fed02a1bdabb2dab559c36498e31b310..472f52380bbf479ac0c22b9218b0637abcc3c4ea 100644 (file)
@@ -213,11 +213,14 @@ fn try_convert_match<'tcx>(
     cx: &LateContext<'tcx>,
     arms: &[Arm<'tcx>],
 ) -> Option<(&'tcx Pat<'tcx>, &'tcx Expr<'tcx>, &'tcx Expr<'tcx>)> {
-    if arms.len() == 2 {
-        return if is_none_or_err_arm(cx, &arms[1]) {
-            Some((arms[0].pat, arms[0].body, arms[1].body))
-        } else if is_none_or_err_arm(cx, &arms[0]) {
-            Some((arms[1].pat, arms[1].body, arms[0].body))
+    if let [first_arm, second_arm] = arms
+        && first_arm.guard.is_none()
+        && second_arm.guard.is_none()
+        {
+        return if is_none_or_err_arm(cx, second_arm) {
+            Some((first_arm.pat, first_arm.body, second_arm.body))
+        } else if is_none_or_err_arm(cx, first_arm) {
+            Some((second_arm.pat, second_arm.body, first_arm.body))
         } else {
             None
         };