-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Tracking Issue for RFC 3535: Constants in Patterns #120362
Copy link
Copy link
Closed
Labels
B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.Blocker: Approved by a merged RFC but not yet implemented.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 RFCT-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.Blocker: Approved by a merged RFC but not yet implemented.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 RFCT-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
This is a tracking issue for the RFC 3535: Constants in Patterns (rust-lang/rfcs#3535).
Summary
When a constant appears as a pattern, this is syntactic sugar for writing a pattern that corresponds to the constant's value by hand. This operation is only allowed when (a) the type of the constant implements
PartialEq, and (b) the value of the constant being matched on has "structural equality", which means thatPartialEqbehaves the same way as that desugared pattern.This RFC does not allow any new code, compared to what already builds on stable today. Its purpose is to explain the rules for constants in patterns in one coherent document, and to justify why we will start rejecting some code that currently works (see the breaking changes).
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
Status of the relevant lints
Unresolved questions
const fn, what exactly should we require? Also see consts in patterns in const contexts with featureeffectscauses warning (soon: error) about not implementing PartialEq #119398.Related issues
illegal_floating_point_literal_patterncompatibility lint #41620indirect_structural_matchcompatibility lint #62411const_patterns_without_partial_eqlint #116122