Skip to content

Alternative noncopyable switch design based on expression kind. #72647

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

Merged

Conversation

jckarter
Copy link
Contributor

If an expression refers to noncopyable storage, then default to performing a borrowing switch, where let bindings in patterns borrow out of the matched value. If an expression refers to a temporary value or explicitly uses the consume keyword, then perform a consuming switch, where let bindings take ownership of corresponding parts of the matched value. Allow _borrowing to still be used to explicitly bind a pattern variable as a borrow, with no-implicit-copy semantics for copyable values.

@jckarter jckarter requested review from kavon, a team, hborla, slavapestov and xedin as code owners March 28, 2024 01:20
@jckarter
Copy link
Contributor Author

@swift-ci Please test

If an expression refers to noncopyable storage, then default to performing
a borrowing switch, where `let` bindings in patterns borrow out of the
matched value. If an expression refers to a temporary value or explicitly
uses the `consume` keyword, then perform a consuming switch, where
`let` bindings take ownership of corresponding parts of the matched value.
Allow `_borrowing` to still be used to explicitly bind a pattern variable
as a borrow, with no-implicit-copy semantics for copyable values.
@jckarter jckarter force-pushed the borrowing-switch-expr-based-ownership branch from f613db4 to ba34948 Compare March 28, 2024 15:32
@jckarter
Copy link
Contributor Author

@swift-ci Please test

Copy link
Member

@kavon kavon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼 LGTM

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