about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/manual_let_else.rs1
-rw-r--r--tests/ui/manual_let_else.rs3
2 files changed, 4 insertions, 0 deletions
diff --git a/clippy_lints/src/manual_let_else.rs b/clippy_lints/src/manual_let_else.rs
index 8d743c86d6d..8a915127c3c 100644
--- a/clippy_lints/src/manual_let_else.rs
+++ b/clippy_lints/src/manual_let_else.rs
@@ -73,6 +73,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualLetElse {
             if !in_external_macro(cx.sess(), stmt.span);
             if let StmtKind::Local(local) = stmt.kind;
             if let Some(init) = local.init;
+            if local.els.is_none();
             if init.span.ctxt() == stmt.span.ctxt();
             if let Some(if_let_or_match) = IfLetOrMatch::parse(cx, init);
             then {
diff --git a/tests/ui/manual_let_else.rs b/tests/ui/manual_let_else.rs
index bd0ac69e46e..9e5df65b74d 100644
--- a/tests/ui/manual_let_else.rs
+++ b/tests/ui/manual_let_else.rs
@@ -194,4 +194,7 @@ fn not_fire() {
         };
     }
     create_binding_if_some_nf!(v, g());
+
+    // Already a let-else
+    let Some(a) = (if let Some(b) = Some(Some(())) { b } else { return }) else { panic!() };
 }