-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@swift-ci test |
meg-gupta
approved these changes
Mar 28, 2024
911f745
to
dd58cf3
Compare
@swift-ci test |
dd58cf3
to
60003ee
Compare
@swift-ci test |
60003ee
to
bb2b4cc
Compare
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)
(cherry picked from commit 7b9da75)
(cherry picked from commit de6e8be)
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)
(cherry picked from commit 1e0035f)
-enable-experimental-feature NonescapableTypes now only controls syntax and some type inferrence features. (cherry picked from commit f19d94c)
bb2b4cc
to
6efcb59
Compare
@swift-ci test |
tbkka
approved these changes
Apr 8, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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