-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
False positive in non_exhaustive_omitted_patterns: matches! #135137
Copy link
Copy link
Closed as duplicate of#117304
Closed as duplicate of#117304
Copy link
Labels
A-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsRelating to exhaustiveness / usefulness checking of patternsA-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-bugCategory: This is a bug.Category: This is a bug.F-non_exhaustive_omitted_patterns_lint`#![feature(non_exhaustive_omitted_patterns_lint)]``#![feature(non_exhaustive_omitted_patterns_lint)]`T-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.
Description
Activity
Metadata
Metadata
Assignees
Labels
A-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsRelating to exhaustiveness / usefulness checking of patternsA-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-bugCategory: This is a bug.Category: This is a bug.F-non_exhaustive_omitted_patterns_lint`#![feature(non_exhaustive_omitted_patterns_lint)]``#![feature(non_exhaustive_omitted_patterns_lint)]`T-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.
I believe the lint should not trigger on this code. For comparison, it correctly does not trigger on this alternative implementation of the same function:
Conceptually, for the purpose of exhaustiveness,
matches!more closely resemblesif letthanmatch, even if the standard library implementation currently involvesmatchinternally in order to support guard expressions.The
non_exhaustive_omitted_patternsshould only trigger on this variation of this function.#![feature(non_exhaustive_omitted_patterns_lint)]#89554