Skip to content

Commit 161f318

Browse files
committed
temporarily disable Span and MutableSpan for Windows
The current Windows nightly is too old to be able to compile the expected syntax.
1 parent 759820e commit 161f318

File tree

3 files changed

+40
-8
lines changed

3 files changed

+40
-8
lines changed

Package.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ let package = Package(
135135
swiftSettings: [
136136
.enableExperimentalFeature("VariadicGenerics"),
137137
.enableExperimentalFeature("LifetimeDependence"),
138+
.enableExperimentalFeature(
139+
"InoutLifetimeDependence",
140+
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
141+
),
142+
.enableExperimentalFeature(
143+
"LifetimeDependenceMutableAccessors",
144+
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
145+
),
138146
.enableExperimentalFeature("AddressableTypes"),
139147
.enableExperimentalFeature("BuiltinModule"),
140148
.enableExperimentalFeature("AccessLevelOnImport")
@@ -152,7 +160,16 @@ let package = Package(
152160
resources: [
153161
.copy("Resources")
154162
],
155-
swiftSettings: availabilityMacros + concurrencyChecking
163+
swiftSettings: [
164+
.enableExperimentalFeature(
165+
"InoutLifetimeDependence",
166+
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
167+
),
168+
.enableExperimentalFeature(
169+
"LifetimeDependenceMutableAccessors",
170+
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
171+
),
172+
] + availabilityMacros + concurrencyChecking
156173
),
157174

158175
// FoundationInternationalization

Sources/FoundationEssentials/Data/Data.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,6 +2239,7 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect
22392239
}
22402240
}
22412241

2242+
#if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
22422243
@available(FoundationSpan 6.2, *)
22432244
public var mutableBytes: MutableRawSpan {
22442245
@lifetime(&self)
@@ -2298,6 +2299,7 @@ public struct Data : Equatable, Hashable, RandomAccessCollection, MutableCollect
22982299
#endif
22992300
}
23002301
}
2302+
#endif // $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
23012303

23022304
@_alwaysEmitIntoClient
23032305
public func withContiguousStorageIfAvailable<ResultType>(_ body: (_ buffer: UnsafeBufferPointer<UInt8>) throws -> ResultType) rethrows -> ResultType? {
@@ -2950,7 +2952,7 @@ extension Data : Codable {
29502952
}
29512953

29522954
// TODO: remove once _overrideLifetime is public in the standard library
2953-
2955+
#if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
29542956
/// Unsafely discard any lifetime dependency on the `dependent` argument. Return
29552957
/// a value identical to `dependent` with a lifetime dependency on the caller's
29562958
/// borrow scope of the `source` argument.
@@ -2964,8 +2966,6 @@ internal func _overrideLifetime<
29642966
>(
29652967
_ dependent: consuming T, borrowing source: borrowing U
29662968
) -> T {
2967-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
2968-
// should be expressed by a builtin that is hidden within the function body.
29692969
dependent
29702970
}
29712971

@@ -2982,8 +2982,6 @@ internal func _overrideLifetime<
29822982
>(
29832983
_ dependent: consuming T, copying source: borrowing U
29842984
) -> T {
2985-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
2986-
// should be expressed by a builtin that is hidden within the function body.
29872985
dependent
29882986
}
29892987

@@ -3001,7 +2999,6 @@ internal func _overrideLifetime<
30012999
_ dependent: consuming T,
30023000
mutating source: inout U
30033001
) -> T {
3004-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
3005-
// should be expressed by a builtin that is hidden within the function body.
30063002
dependent
30073003
}
3004+
#endif // $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors

Tests/FoundationEssentialsTests/DataTests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,7 @@ class DataTests : XCTestCase {
16371637
func test_InlineDataSpan() throws {
16381638
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
16391639

1640+
#if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
16401641
var source = Data()
16411642
var span = source.span
16421643
XCTAssertTrue(span.isEmpty)
@@ -1646,15 +1647,18 @@ class DataTests : XCTestCase {
16461647
XCTAssertFalse(span.isEmpty)
16471648
XCTAssertEqual(span.count, source.count)
16481649
XCTAssertEqual(span[0], 1)
1650+
#endif
16491651
}
16501652

16511653
func test_InlineSliceDataSpan() throws {
16521654
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
16531655

1656+
#if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
16541657
let source = Data(0 ... .max)
16551658
let span = source.span
16561659
XCTAssertEqual(span.count, source.count)
16571660
XCTAssertEqual(span[span.indices.last!], .max)
1661+
#endif
16581662
}
16591663

16601664
func test_LargeSliceDataSpan() throws {
@@ -1668,15 +1672,18 @@ class DataTests : XCTestCase {
16681672
#error("This test needs updating")
16691673
#endif
16701674

1675+
#if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
16711676
let source = Data(repeating: 0, count: count).dropFirst()
16721677
XCTAssertNotEqual(source.startIndex, 0)
16731678
let span = source.span
16741679
XCTAssertFalse(span.isEmpty)
1680+
#endif
16751681
}
16761682

16771683
func test_InlineDataMutableSpan() throws {
16781684
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
16791685

1686+
#if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
16801687
var source = Data()
16811688
var span = source.mutableSpan
16821689
XCTAssertTrue(span.isEmpty)
@@ -1690,18 +1697,21 @@ class DataTests : XCTestCase {
16901697
let v = UInt8.random(in: 10..<100)
16911698
span[i] = v
16921699
XCTAssertEqual(source[i], v)
1700+
#endif
16931701
}
16941702

16951703
func test_InlineSliceDataMutableSpan() throws {
16961704
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
16971705

1706+
#if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
16981707
var source = Data(0..<100)
16991708
let count = source.count
17001709
var span = source.mutableSpan
17011710
XCTAssertEqual(span.count, count)
17021711
let i = try XCTUnwrap(span.indices.randomElement())
17031712
span[i] = .max
17041713
XCTAssertEqual(source[i], .max)
1714+
#endif
17051715
}
17061716

17071717
func test_LargeSliceDataMutableSpan() throws {
@@ -1715,6 +1725,7 @@ class DataTests : XCTestCase {
17151725
#error("This test needs updating")
17161726
#endif
17171727

1728+
#if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
17181729
var source = Data(repeating: 0, count: count).dropFirst()
17191730
XCTAssertNotEqual(source.startIndex, 0)
17201731
count = source.count
@@ -1724,11 +1735,13 @@ class DataTests : XCTestCase {
17241735
span[i] = .max
17251736
XCTAssertEqual(source[i], 0)
17261737
XCTAssertEqual(source[i+1], .max)
1738+
#endif
17271739
}
17281740

17291741
func test_InlineDataMutableRawSpan() throws {
17301742
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
17311743

1744+
#if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
17321745
var source = Data()
17331746
var span = source.mutableBytes
17341747
XCTAssertTrue(span.isEmpty)
@@ -1742,18 +1755,21 @@ class DataTests : XCTestCase {
17421755
let v = UInt8.random(in: 10..<100)
17431756
span.storeBytes(of: v, toByteOffset: i, as: UInt8.self)
17441757
XCTAssertEqual(source[i], v)
1758+
#endif
17451759
}
17461760

17471761
func test_InlineSliceDataMutableRawSpan() throws {
17481762
guard #available(FoundationSpan 6.2, *) else { throw XCTSkip("Span not available") }
17491763

1764+
#if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
17501765
var source = Data(0..<100)
17511766
let count = source.count
17521767
var span = source.mutableBytes
17531768
XCTAssertEqual(span.byteCount, count)
17541769
let i = try XCTUnwrap(span.byteOffsets.randomElement())
17551770
span.storeBytes(of: -1, toByteOffset: i, as: Int8.self)
17561771
XCTAssertEqual(source[i], .max)
1772+
#endif
17571773
}
17581774

17591775
func test_LargeSliceDataMutableRawSpan() throws {
@@ -1767,6 +1783,7 @@ class DataTests : XCTestCase {
17671783
#error("This test needs updating")
17681784
#endif
17691785

1786+
#if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
17701787
var source = Data(repeating: 0, count: count).dropFirst()
17711788
XCTAssertNotEqual(source.startIndex, 0)
17721789
count = source.count
@@ -1776,6 +1793,7 @@ class DataTests : XCTestCase {
17761793
span.storeBytes(of: -1, toByteOffset: i, as: Int8.self)
17771794
XCTAssertEqual(source[i], 0)
17781795
XCTAssertEqual(source[i+1], .max)
1796+
#endif
17791797
}
17801798

17811799
#if false // FIXME: XCTest doesn't support crash tests yet rdar://20195010&22387653

0 commit comments

Comments
 (0)