Skip to content

[6.2] Disallow @_lifetime(borrow) for trivial 'inout' arguments #82217

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 3 commits into from
Jun 14, 2025

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Jun 12, 2025

  • [NFC] LifetimeDependence: fix indentation
    To avoid diff/merge confusion.

    (cherry picked from commit 9dd88e2)

  • Disallow @_lifetime(borrow) for trivial 'inout' arguments
    @_lifetime(borrow holder) // ERROR
    func test(holder: inout Holder) -> NE

    Fixes rdar://153040843 ([nonescapable] disallow @_lifetime(borrow)
    for trivial 'inout' arguments)

    (cherry picked from commit a389254)

  • Update tests after disallowing @_lifetime(borrow) for inout
    (cherry picked from commit f6c7524)

--- CCC ---

Explanation: Preemptively prohibit the following two forms of nonsense syntax. It's a common mistake. Fixing it is source-breaking, but the syntax was introduced very recently. The sooner we fix this, the better.

@_lifetime(borrow holder) // ERROR
func test(holder: inout Holder) -> NE

@_lifetime(&holder) // ERROR
func test(holder: borrowing Holder) -> NE

Scope: Only affects users of the supported experiment Lifetimes feature.

Radar/SR Issue: rdar://153040843 ([nonescapable] disallow @_lifetime(borrow) for trivial 'inout' arguments)

main PR: #82189

Risk: Low

Testing: Added a matrix of unit tests

Reviewer: Meghana Gupta

@atrick atrick requested a review from a team as a code owner June 12, 2025 17:37
@atrick atrick added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Jun 12, 2025
@atrick
Copy link
Contributor Author

atrick commented Jun 12, 2025

@swift-ci test

@atrick atrick enabled auto-merge June 12, 2025 17:38
@atrick atrick requested review from meg-gupta and tbkka June 12, 2025 17:38
@atrick atrick changed the title [6.2] Update tests after disallowing @_lifetime(borrow) for inout [6.2] Disallow @_lifetime(borrow) for trivial 'inout' arguments Jun 12, 2025
atrick added 3 commits June 12, 2025 16:03
To avoid diff/merge confusion.

(cherry picked from commit 9dd88e2)
    @_lifetime(borrow holder) // ERROR
    func test(holder: inout Holder) -> NE

Fixes rdar://153040843 ([nonescapable] disallow @_lifetime(borrow)
for trivial 'inout' arguments)

(cherry picked from commit a389254)
@atrick atrick force-pushed the 62-lifedep-trivial-inout branch from 046c61d to 4f337f0 Compare June 13, 2025 01:00
@meg-gupta
Copy link
Contributor

@swift-ci test

@atrick atrick merged commit a358403 into swiftlang:release/6.2 Jun 14, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 6.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants