Skip to content

Commit d9366d6

Browse files
authored
Merge pull request #1590 from glessard/update-lifetimes-feature
Update lifetimes feature (future)
2 parents b9dfce8 + 6487b05 commit d9366d6

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ let package = Package(
148148
] + wasiLibcCSettings,
149149
swiftSettings: [
150150
.enableExperimentalFeature("VariadicGenerics"),
151-
.enableExperimentalFeature("LifetimeDependence"),
151+
.enableExperimentalFeature("Lifetimes"),
152152
.enableExperimentalFeature("AddressableTypes"),
153153
.enableExperimentalFeature("AllowUnsafeAttribute"),
154154
.enableExperimentalFeature("BuiltinModule"),

Sources/FoundationEssentials/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ endif()
8484

8585
target_compile_options(FoundationEssentials PRIVATE
8686
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend VariadicGenerics>"
87-
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend LifetimeDependence>"
87+
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend Lifetimes>"
8888
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend AddressableTypes>"
8989
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend BuiltinModule>"
9090
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend AccessLevelOnImport>"

Sources/FoundationEssentials/Data/Data+Reading.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ struct ReadBytesResult {
193193
}
194194

195195
#if os(Windows)
196-
@lifetime(pBuffer: copy pBuffer)
196+
@_lifetime(pBuffer: copy pBuffer)
197197
private func read(from hFile: HANDLE, at path: PathOrURL,
198198
into pBuffer: inout OutputRawSpan,
199199
chunkSize dwChunk: Int = 4096, progress bProgress: Bool)

Sources/FoundationEssentials/Data/Data.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public struct Data : RandomAccessCollection, MutableCollection, RangeReplaceable
353353
@available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *)
354354
@_alwaysEmitIntoClient
355355
public var bytes: RawSpan {
356-
@lifetime(borrow self)
356+
@_lifetime(borrow self)
357357
borrowing get {
358358
let buffer: UnsafeRawBufferPointer
359359
switch _representation {
@@ -381,7 +381,7 @@ public struct Data : RandomAccessCollection, MutableCollection, RangeReplaceable
381381
@available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *)
382382
@_alwaysEmitIntoClient
383383
public var span: Span<UInt8> {
384-
@lifetime(borrow self)
384+
@_lifetime(borrow self)
385385
borrowing get {
386386
let span = unsafe bytes._unsafeView(as: UInt8.self)
387387
return _overrideLifetime(span, borrowing: self)
@@ -391,7 +391,7 @@ public struct Data : RandomAccessCollection, MutableCollection, RangeReplaceable
391391
@available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *)
392392
@_alwaysEmitIntoClient
393393
public var mutableBytes: MutableRawSpan {
394-
@lifetime(&self)
394+
@_lifetime(&self)
395395
mutating get {
396396
let buffer: UnsafeMutableRawBufferPointer
397397
switch _representation {
@@ -427,7 +427,7 @@ public struct Data : RandomAccessCollection, MutableCollection, RangeReplaceable
427427
@available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *)
428428
@_alwaysEmitIntoClient
429429
public var mutableSpan: MutableSpan<UInt8> {
430-
@lifetime(&self)
430+
@_lifetime(&self)
431431
mutating get {
432432
#if false // see https://github.com/swiftlang/swift/issues/81218
433433
var bytes = mutableBytes

Sources/FoundationEssentials/String/String+IO.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,8 @@ extension StringProtocol {
456456
let options : Data.WritingOptions = useAuxiliaryFile ? [.atomic] : []
457457
#endif
458458

459-
try writeToFile(path: .path(String(path)), buffer: data.bytes, options: options, attributes: attributes, reportProgress: false)
459+
let bytes = data.bytes
460+
try writeToFile(path: .path(String(path)), buffer: bytes, options: options, attributes: attributes, reportProgress: false)
460461
}
461462

462463
/// Writes the contents of the `String` to the URL specified by url using the specified encoding.

0 commit comments

Comments
 (0)