-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Tracking Issue for Never Patterns (never_patterns) #118155
Copy link
Copy link
Open
Labels
A-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsRelating to exhaustiveness / usefulness checking of patternsB-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).Blocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-never_patterns`#![feature(never_patterns)]``#![feature(never_patterns)]`S-tracking-impl-incompleteStatus: The implementation is incomplete.Status: The implementation is incomplete.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsRelating to exhaustiveness / usefulness checking of patternsB-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).Blocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-never_patterns`#![feature(never_patterns)]``#![feature(never_patterns)]`S-tracking-impl-incompleteStatus: The implementation is incomplete.Status: The implementation is incomplete.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
Exploration
View all comments
This is a tracking issue for the experimental "never patterns" feature (as per the T-lang experimental feature process).
The feature gate for the issue is
#![feature(never_patterns)].RFC: rust-lang/rfcs#3719
This feature introduces a new syntax for patterns:
!. In a pattern,!is valid for any uninhabited type and simply acknowledges that the type is empty. Because a never pattern is statically known to be unreachable, it obeys slightly different rules:This feature does not affect exhaustiveness or pattern reachability; see the
exhaustive_patternsandmin_exhaustive_patternsfeatures for that.About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
Unresolved Questions
Implementation plans/details
!is parsed as a pattern.matchexpressions allowsmatch <expr> { <pat>, ... }i.e. a pattern without a body. We later check to only allow that if the pattern is a never pattern.unreachable_unchecked!().Ok(x) | Err(!)(x, !)fn foo(!: Void) -> SomeType {}!is typechecked like a wildcard; it adds no type constraint!is only used on an uninhabited type (modulo match ergonomics).!pattern is lowered to MIR.!pattern asserts validiy of the matched place!.!argument not detected as diverging on async fn #120240Implementation history
never_patternsfeature gate #118157!bindings as diverging #120104!to_. #120517!patterns on non-exhaustive matches #121823Unreachablein MIR #123332