Skip to content

[6.0🍒] Consume: warn about no-op consumes to be fixed #75457

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
merged 2 commits into from
Jul 25, 2024

Conversation

kavon
Copy link
Member

@kavon kavon commented Jul 24, 2024

  • Explanation: Adds a warning for specific uses of consume that are known to be effectively no-ops in SIL, so they're not actually consuming anything. We plan to fix this in the future, which will result in source breaks in the future for code such as:
let someInt = 10
let y = consume someInt
print(someInt) // no error!
  • Scope: Only adds one warning.
  • Issue: rdar://127081103
  • Original PR: Consume: warn about no-op consumes to be fixed #75449
  • Risk: Low. Will only break builds for people who use -warnings-as-errors. There is a fix-it to remove the offending consume.
  • Testing: Swift CI.
  • Reviewer: TBD

kavon added 2 commits July 24, 2024 16:10
As of now, SE-366 is not correctly implemented with respect to concrete,
bitwise-copyable types like `Int`. Writing `consume someInt` doesn't
actually consume the variable binding as it should, meaning code that
should be flagged as having a use-after-consume is being silently
permitted:

```swift
let someInt = 10
let y = consume someInt
print(someInt) // no error!
```

This has been a problem since Swift 5.9. Eventually we plan to fix this
issue, which means code previously doing the above would become an
error. To help people get ready for the fix, start warning people that
these consumes are actually no-ops and suggest removing them until the
intended behavior is actually enforced in the future.

resolves rdar://127081103

(cherry picked from commit e04b35d)
@kavon kavon requested a review from a team as a code owner July 24, 2024 23:14
@kavon kavon requested review from nate-chandler and jckarter July 24, 2024 23:14
@kavon
Copy link
Member Author

kavon commented Jul 24, 2024

@swift-ci test

@kavon kavon enabled auto-merge July 24, 2024 23:14
@kavon kavon disabled auto-merge July 25, 2024 03:24
@kavon kavon enabled auto-merge July 25, 2024 03:50
@kavon kavon merged commit 11cba20 into swiftlang:release/6.0 Jul 25, 2024
5 checks passed
@kavon kavon deleted the 6.0-warn-noop-consumes branch July 29, 2024 18:20
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.

3 participants