Skip to content

[6.0] Fix LifetimeDependenceDiagnostics to ignore closure captures #72666

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 7 commits into from
Apr 9, 2024

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Mar 28, 2024

Fix LifetimeDependenceDiagnostics to ignore closure captures

ClosureLifetimeFixup now emits mark_dependence [nonescaping]. Those should be
ignored by diagnostics. In the capture case, the dependence has already been
resolved, and may not match the SIL patterns that we expect for source-level
lifetime dependencies.

Fixes rdar://125375685 ([nonescapable] Fix lifetime-dependence diagnostics in the stdlib)x

This allows us to always-enable lifetime-depenence diagnostics.

This PR also includes obvious, harmless fixes to move-only diagnostics to allow adding
nonescapable unit tests.

Fix MoveOnlyDiagnostics, ConsumOperator...Checkers diagnostics

Emitting a note with an invalid source location is actively
harmful. It confuses users and tools, makes it impossible to write
unit tests. In this case, the note simply says "use here", so it's
completely free of information without the source location.

--- CCC ---

Explanation: Fix LifetimeDependenceDiagnostics to ignore closure captures

Scope: Allows NonescapableTypes to be enabled by default

Radar/SR Issue: rdar://125375685 ([nonescapable] Fix lifetime-dependence diagnostics in the stdlib)

Original PR: #72635

Risk: This bypasses new compiler functionality for code that does not require that functionality. It lowers risk.

Testing: Unit tests added

Reviewer: @meg-gupta

@atrick atrick added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.0 labels Mar 28, 2024
@atrick atrick requested a review from meg-gupta March 28, 2024 17:00
@atrick atrick requested a review from a team as a code owner March 28, 2024 17:00
@atrick
Copy link
Contributor Author

atrick commented Mar 28, 2024

@swift-ci test

@atrick atrick force-pushed the 60-fix-lifedep-capture branch from 911f745 to dd58cf3 Compare March 28, 2024 22:07
@atrick
Copy link
Contributor Author

atrick commented Mar 28, 2024

@swift-ci test

@atrick
Copy link
Contributor Author

atrick commented Apr 2, 2024

@swift-ci test

@atrick atrick force-pushed the 60-fix-lifedep-capture branch from 60003ee to bb2b4cc Compare April 4, 2024 16:44
atrick added 7 commits April 8, 2024 12:19
This fixes bugs when ~Escapable types depended on values that are passed to 'consume'.

The consume operator diagnostics are broken when dependent values are
present. This sidesteps the problem for lifetime dependence. And we
generally want to diagnose lifetime dependence after all move-only
related diagnostics. That way, using a dependent value after consume
provides a more informative diagnostic about the dependent value and
its scope.

(cherry picked from commit 6b776f5)
Emitting a note with an invalid source location is actively
harmful. It confuses users and tools, makes it impossible to write
unit tests. In this case, the note simply says "use here", so it's
completely free of information without the source location.

(cherry picked from commit a99ea62)
ClosureLifetimeFixup now emits mark_dependence [nonescaping]. Those should be
ignored by diagnostics. In the capture case, the dependence has already been
resolved, and may not match the SIL patterns that we expect for source-level
lifetime dependencies.

Fixes rdar://125375685 ([nonescapable] Fix lifetime-dependence diagnostics in the stdlib)

(cherry picked from commit 36b9ed4)
-enable-experimental-feature NonescapableTypes now only controls syntax and some type inferrence features.

(cherry picked from commit f19d94c)
@atrick atrick force-pushed the 60-fix-lifedep-capture branch from bb2b4cc to 6efcb59 Compare April 8, 2024 19:20
@atrick
Copy link
Contributor Author

atrick commented Apr 8, 2024

@swift-ci test

@atrick atrick merged commit 95e568b into swiftlang:release/6.0 Apr 9, 2024
@atrick atrick deleted the 60-fix-lifedep-capture branch April 9, 2024 05:30
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.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants