-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix LifetimeDependenceDiagnostics to ignore closure captures #72635
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
Conversation
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.
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.
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)
-enable-experimental-feature NonescapableTypes now only controls syntax and some type inferrence features.
@swift-ci test |
@swift-ci benchmark |
@swift-ci test source compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
// | ||
// FIXME: why is DeinitDevirtualizer in the middle of the mandatory pipeline, | ||
// and what passes/compilation modes depend on it? This pass is never executed | ||
// or tested without '-Xllvm enable-deinit-devirtualizer'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eeckstein if you know why the DeinitDevirtualizer runs in the middle of the mandatory pipeline or know of any passes that depend on it, in embedded mode or otherwise, please document that in the pass header. I couldn't figure it out after wasting an hour investigating.
@swift-ci Please Build Toolchain macOS Platform |
source compat Siesta appears to be failing on main also |
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.