Commit Graph

16 Commits

Author SHA1 Message Date
Meghana Gupta
8d3f38623d [NFC] Update tests and diagnostics 2025-06-11 13:15:22 -07:00
Andrew Trick
64a48d08e1 Update tests for strict @lifetime type checking 2025-03-19 11:59:04 -07:00
Meghana Gupta
e8abd59da5 Update tests 2024-11-18 18:09:19 -08:00
Meghana Gupta
84a0d9c0b2 Remove -disable-experimental-parser-round-trip from @lifetime tests 2024-11-07 14:38:01 -08:00
Daniel Rodríguez Troitiño
ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00
Rintaro Ishizaki
ba485d4630 [Test] Disable experimental parser round-trip in '@lifetime' test cases
Until SwiftParser supports the syntax

rdar://137636751
2024-10-09 23:52:52 -07:00
Meghana Gupta
008431c3b4 Update some dependsOn tests to @lifetime 2024-10-08 15:12:13 -07:00
Andrew Trick
b5b0c75ccd Remove diagnostic: lifetime_dependence_on_bitwise_copyable
Allow lifetime depenendence on types that are BitwiseCopyable & Escapable.

This is unsafe in the sense that the compiler will not diagnose any use of the
dependent value outside of the lexcial scope of the source value. But, in
practice, dependence on an UnsafePointer is often needed. In that case, the
programmer should have already taken responsibility for ensuring the lifetime of the
pointer over all dependent uses. Typically, an unsafe pointer is valid for the
duration of a closure. Lifetime dependence prevents the dependent value from
being returned by the closure, so common usage is safe by default.

Typical example:

func decode(_ bufferRef: Span<Int>) { /*...*/ }

extension UnsafeBufferPointer {
  // The client must ensure the lifetime of the buffer across the invocation of `body`.
  // The client must ensure that no code modifies the buffer during the invocation of `body`.
  func withUnsafeSpan<Result>(_ body: (Span<Element>) throws -> Result) rethrows -> Result {
    // Construct Span using its internal, unsafe API.
    try body(Span(unsafePointer: baseAddress!, count: count))
  }
}

func decodeArrayAsUBP(array: [Int]) {
  array.withUnsafeBufferPointer { buffer in
    buffer.withUnsafeSpan {
      decode($0)
    }
  }
}

In the future, we may add SILGen support for tracking the lexical scope of
BitwiseCopyable values. That would allow them to have the same dependence
behavior as other source values.
2024-05-22 17:10:56 -07:00
Kavon Farvardin
0420310623 NCGenerics: it's no longer "experimental"
resolves rdar://127701059
2024-05-08 10:49:12 -07:00
Nate Chandler
b1fbe4ea91 [BitwiseCopyable] Remove underscore. 2024-04-25 11:44:15 -07:00
Nate Chandler
ed5c7ef7ae [BitwiseCopyable] Promote to feature.
SE-0426 was accepted.
2024-04-24 15:52:20 -07:00
Meghana Gupta
b835c14964 LifetimeDependence inference, dont use BitwiseCopyable type as candidate 2024-04-16 13:19:45 -07:00
Meghana Gupta
c8c1f17821 Update lifetime dependence diagnostic message 2024-04-08 22:33:32 -07:00
Meghana Gupta
5a96e6c199 Add -disable-availability-checking to the required test 2024-03-28 18:27:13 -07:00
Meghana Gupta
60558f4d8f NFC: Add Sema test for lifetime dependence 2024-03-28 12:22:34 -07:00
Meghana Gupta
11d5179587 Allow lifetime dependence inference on implicit initializers 2024-03-26 21:51:50 -07:00