-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
false positive for if-let-rescope on enums when the pattern exhaustively matches all cases with significant-drop fields #137376
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-edition-2024Area: The 2024 editionArea: The 2024 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-edition-triagedIssue: This issue has been reviewed and triaged by the Edition team.Issue: This issue has been reviewed and triaged by the Edition team.L-false-positiveLint: False positive (should not have fired).Lint: False positive (should not have fired).L-if_let_rescopeLint: if_let_rescopeLint: if_let_rescopeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-edition-2024Area: The 2024 editionArea: The 2024 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-edition-triagedIssue: This issue has been reviewed and triaged by the Edition team.Issue: This issue has been reviewed and triaged by the Edition team.L-false-positiveLint: False positive (should not have fired).Lint: False positive (should not have fired).L-if_let_rescopeLint: if_let_rescopeLint: if_let_rescopeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Coming from #133167 (comment) and from this new forum thread, my takeaway of some remaining clear false positives is:
if the
if letmatches on an enum and only some enum variant(s) have fields with potentially-significant destructor, but those are exhaustively matched in the non-elsecase of theif let, then there can be no actual change in behavior, because theelsecase is only reached in case the drop is not significantin the case of
cargo-edit, this wasif let Some(…irrefutable…) = expron 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
Optioncase:Code
Here’s the code in the playground.
Current output
@rustbot label A-edition-2024, A-lints, L-if_let_rescope, C-enhancement