Skip to content

[5.9] Require switch on a noncopyable-type binding to be explicitly consume-d. #66343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jckarter
Copy link
Contributor

@jckarter jckarter commented Jun 5, 2023

• Issue: rdar://110073984
• Explanation: Pattern matching as currently implemented is consuming, but that's not necessarily what we want to be the default behavior when borrowing pattern matching is implemented. When a binding of noncopyable type is pattern-matched, require it to be annotated with the consume operator explicitly. That way, when we introduce borrowing pattern matching later, we have the option to make switch x do the right thing without subtly changing the behavior of existing code.
• Scope of Issue: New feature.
• Origination: Design decision from the Swift Language Steering Group.
• Risk: Low. Only affects new code using noncopyable enums.
• Pull Request URL: #65986
• Reviewed By: @hamishknight and @gottesmm
• Automated Testing: Swift CI
• Dependencies: None
• Builder Impact: Not applicable
• Directions for QE: None

…ume`-d.

Pattern matching as currently implemented is consuming, but that's not
necessarily what we want to be the default behavior when borrowing pattern
matching is implemented. When a binding of noncopyable type is pattern-matched,
require it to be annotated with the `consume` operator explicitly. That way,
when we introduce borrowing pattern matching later, we have the option to make
`switch x` do the right thing without subtly changing the behavior of existing
code. rdar://110073984
@jckarter jckarter requested a review from a team as a code owner June 5, 2023 17:26
@jckarter
Copy link
Contributor Author

jckarter commented Jun 5, 2023

@swift-ci Please test

@jckarter jckarter merged commit 2338480 into swiftlang:release/5.9 Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants