-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
unreachable_patterns lint due to min_exhaustive_patterns #129031
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.F-min_exhaustive_patterns`#![feature(min_exhaustive_patterns)]``#![feature(min_exhaustive_patterns)]`L-unreachable_patternsLint: unreachable_patternsLint: unreachable_patternsT-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.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.F-min_exhaustive_patterns`#![feature(min_exhaustive_patterns)]``#![feature(min_exhaustive_patterns)]`L-unreachable_patternsLint: unreachable_patternsLint: unreachable_patternsT-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.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
Code
Current output
Desired output
Until the 2024 edition, or the code's MSRV is ≥ 1.82, no warning.
Rationale and extra context
Deleting the
Err(e) => match e {}arm will produce code which does not warn on nightly/1.82, but which does not compile on 1.80. This means that users which wish to keep a warning-free-ish nightly (or beta, eventually) build will have to#[allow(unreachable_patterns)]from now until 1.82 is released, or perhaps even until their next MSRV increase.Deferring the warning until an edition or explicit MSRV increase seems to me to be a good way to avoid churn in the form of
#[allow]s. Such#[allow]s are particularly dangerous becauseunreachable_patternsis also the lint that detects binding patterns that were intended to be matching against constants instead, so declaring it on a wide scope might hide serious bugs, especially if (as is likely) they're not promptly removed upon the release of 1.82.Rust Version
Anything else?
I noticed this due to my CI against nightly, but comments on the stabilization PR #122792 (comment) mentioned it first. I'm filing this issue to make sure it is not overlooked by being only visible in that comment thread.