Skip to content

[6.0] Fix LifetimeDependenceDiagnostics to ignore closure captures #72665

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

Closed
wants to merge 334 commits into from

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

lorentey and others added 30 commits March 19, 2024 11:18
…ift, obsoleted: 1)`

Using version `2` here is just weird for no reason.
It’s a caseless enum, but there’s no reason to change this aspect of it.
…events toolchain builds from succeeding"

This reverts commit 0266c6d.
[gardening] update copyright notice

[gardening] update copyright notice

[gardening] update copyright notice

[gardening] update copyright notice
…rk when using Optional and other stdlib features
Fixes the missing diagnostic about the availability of the setter of `x` in the
following example:

```
struct S {
  var x: Int {
    get { 0 }
    @available(*, unavailable) set {}
  }
}

var s = S()
s[keyPath: \.x] = 1
```

Resolves rdar://124977727
In the following example, the writeback via the property `b` should be
diagnosed since `b`'s setter is unavailable:

```
struct A {
  struct B {
    var x: Int = 0
  }

  private var _b: B = B()
  var b: B {
    get { _b }
    @available(*, unavailable) set {
      _b = newValue
    }
  }
}

var a = A()
a.b.x = 1
```

Resolves rdar://125019717
When inserting type checks for pre-specialized functions, the existing return-block can only be re-used if it has no arguments.
Otherwise we are creating an argument-less branch to a block with arguments.

rdar://124638266
[6.0] Serialization: update for new diagnostics format
[6.0][CSSimplify] Mark all type variables in member type as holes if base is a hole
atrick added 3 commits March 28, 2024 09:48
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
Copy link
Contributor Author

atrick commented Mar 28, 2024

Hit save too soon

@atrick atrick closed this Mar 28, 2024
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.