Skip to content

Commit e2a3b23

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 a02e0b7 commit e2a3b23

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
@@ -136,6 +136,14 @@ let package = Package(
136136
swiftSettings: [
137137
.enableExperimentalFeature("VariadicGenerics"),
138138
.enableExperimentalFeature("LifetimeDependence"),
139+
.enableExperimentalFeature(
140+
"InoutLifetimeDependence",
141+
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
142+
),
143+
.enableExperimentalFeature(
144+
"LifetimeDependenceMutableAccessors",
145+
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
146+
),
139147
.enableExperimentalFeature("AddressableTypes"),
140148
.enableExperimentalFeature("BuiltinModule"),
141149
.enableExperimentalFeature("AccessLevelOnImport")
@@ -153,7 +161,16 @@ let package = Package(
153161
resources: [
154162
.copy("Resources")
155163
],
156-
swiftSettings: availabilityMacros + featureSettings
164+
swiftSettings: [
165+
.enableExperimentalFeature(
166+
"InoutLifetimeDependence",
167+
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
168+
),
169+
.enableExperimentalFeature(
170+
"LifetimeDependenceMutableAccessors",
171+
.when(platforms: [.macOS, .iOS, .watchOS, .tvOS, .linux])
172+
),
173+
] + availabilityMacros + featureSettings
157174
),
158175

159176
// 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? {
@@ -2972,7 +2974,7 @@ extension Data : Codable {
29722974
}
29732975

29742976
// TODO: remove once _overrideLifetime is public in the standard library
2975-
2977+
#if $InoutLifetimeDependence && $LifetimeDependenceMutableAccessors
29762978
/// Unsafely discard any lifetime dependency on the `dependent` argument. Return
29772979
/// a value identical to `dependent` with a lifetime dependency on the caller's
29782980
/// borrow scope of the `source` argument.
@@ -2986,8 +2988,6 @@ internal func _overrideLifetime<
29862988
>(
29872989
_ dependent: consuming T, borrowing source: borrowing U
29882990
) -> T {
2989-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
2990-
// should be expressed by a builtin that is hidden within the function body.
29912991
dependent
29922992
}
29932993

@@ -3004,8 +3004,6 @@ internal func _overrideLifetime<
30043004
>(
30053005
_ dependent: consuming T, copying source: borrowing U
30063006
) -> T {
3007-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
3008-
// should be expressed by a builtin that is hidden within the function body.
30093007
dependent
30103008
}
30113009

@@ -3023,7 +3021,6 @@ internal func _overrideLifetime<
30233021
_ dependent: consuming T,
30243022
mutating source: inout U
30253023
) -> T {
3026-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
3027-
// should be expressed by a builtin that is hidden within the function body.
30283024
dependent
30293025
}
3026+
#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)