false positive for if-let-rescope
on enums when the pattern exhaustively matches all cases with significant-drop fields
#137376
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-edition-2024
Area: The 2024 edition
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
L-if_let_rescope
Lint: if_let_rescope
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Coming from #133167 (comment) and from this new forum thread, my takeaway of some remaining clear false positives is:
if the
if let
matches on an enum and only some enum variant(s) have fields with potentially-significant destructor, but those are exhaustively matched in the non-else
case of theif let
, then there can be no actual change in behavior, because theelse
case is only reached in case the drop is not significantin the case of
cargo-edit
, this wasif let Some(…irrefutable…) = expr
on anOption<T>
in the urlo thread, I’ve identified the case of
if let Err(…irrefutable…)
on aResult<(), E>
Here’s a simple repro for an
Option
case:Code
Here’s the code in the playground.
Current output
@rustbot label A-edition-2024, A-lints, L-if_let_rescope, C-enhancement
The text was updated successfully, but these errors were encountered: