Don't lint if the let is already a let-else

We cannot apply the lint for 3-branches like in the added example.
This commit is contained in:
oxalica 2022-10-10 16:00:33 +02:00 committed by est31
parent a1db9311dc
commit 01e651f2fe
2 changed files with 4 additions and 0 deletions

View File

@ -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 {

View File

@ -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!() };
}