Skip to content

Commit 3a574c0

Browse files
committed
stdlib: Address StrictMemorySafety warnings in Concurrency related code.
1 parent dbd3d40 commit 3a574c0

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

stdlib/public/Concurrency/AsyncStreamBuffer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ extension AsyncStream {
252252
func next() async -> Element? {
253253
await withTaskCancellationHandler {
254254
unsafe await withUnsafeContinuation {
255-
next($0)
255+
unsafe next($0)
256256
}
257257
} onCancel: { [cancel] in
258258
cancel()
@@ -512,7 +512,7 @@ extension AsyncThrowingStream {
512512
func next() async throws -> Element? {
513513
try await withTaskCancellationHandler {
514514
try unsafe await withUnsafeThrowingContinuation {
515-
next($0)
515+
unsafe next($0)
516516
}
517517
} onCancel: { [cancel] in
518518
cancel()

stdlib/public/Concurrency/Deque/Deque+Collection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ extension _Deque: Sequence {
9393
}
9494

9595
__consuming func _copyToContiguousArray() -> ContiguousArray<Element> {
96-
ContiguousArray(unsafeUninitializedCapacity: _storage.count) { target, count in
96+
unsafe ContiguousArray(unsafeUninitializedCapacity: _storage.count) { target, count in
9797
unsafe _storage.read { source in
9898
let segments = unsafe source.segments()
9999
let c = unsafe segments.first.count

stdlib/public/Concurrency/Deque/Deque+Testing.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ extension _Deque {
6262
}
6363
let storage = unsafe _Deque<Element>._Storage(unsafeDowncast(buffer, to: _DequeBuffer.self))
6464
if contents.count > 0 {
65-
contents.withUnsafeBufferPointer { source in
65+
unsafe contents.withUnsafeBufferPointer { source in
6666
unsafe storage.update { target in
6767
let segments = unsafe target.mutableSegments()
6868
let c = unsafe segments.first.count

stdlib/public/Concurrency/Task+startSynchronously.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ extension Task where Failure == ${FAILURE_TYPE} {
7676
#if $BuiltinCreateAsyncTaskName
7777
if let name {
7878
task =
79-
name.utf8CString.withUnsafeBufferPointer { nameBytes in
79+
unsafe name.utf8CString.withUnsafeBufferPointer { nameBytes in
8080
Builtin.createTask(
8181
flags: flags,
8282
taskName: nameBytes.baseAddress!._rawValue,

stdlib/public/Concurrency/Task.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ extension Task where Failure == Never {
731731
#if $BuiltinCreateAsyncTaskName
732732
if let name {
733733
task =
734-
name.utf8CString.withUnsafeBufferPointer { nameBytes in
734+
unsafe name.utf8CString.withUnsafeBufferPointer { nameBytes in
735735
Builtin.createTask(
736736
flags: flags,
737737
initialSerialExecutor: builtinSerialExecutor,
@@ -900,7 +900,7 @@ self._task = task
900900
#if $BuiltinCreateAsyncTaskName
901901
if let name {
902902
task =
903-
name.utf8CString.withUnsafeBufferPointer { nameBytes in
903+
unsafe name.utf8CString.withUnsafeBufferPointer { nameBytes in
904904
Builtin.createTask(
905905
flags: flags,
906906
initialSerialExecutor: builtinSerialExecutor,
@@ -1041,7 +1041,7 @@ extension Task where Failure == Never {
10411041
#if $BuiltinCreateAsyncTaskName
10421042
if let name {
10431043
task =
1044-
name.utf8CString.withUnsafeBufferPointer { nameBytes in
1044+
unsafe name.utf8CString.withUnsafeBufferPointer { nameBytes in
10451045
Builtin.createTask(
10461046
flags: flags,
10471047
initialSerialExecutor: builtinSerialExecutor,
@@ -1183,7 +1183,7 @@ extension Task where Failure == Error {
11831183
#if $BuiltinCreateAsyncTaskName
11841184
if let name {
11851185
task =
1186-
name.utf8CString.withUnsafeBufferPointer { nameBytes in
1186+
unsafe name.utf8CString.withUnsafeBufferPointer { nameBytes in
11871187
Builtin.createTask(
11881188
flags: flags,
11891189
initialSerialExecutor: builtinSerialExecutor,

stdlib/public/Concurrency/TaskGroup+addTask.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ extension ${TYPE} {
262262
#if $BuiltinCreateAsyncTaskName
263263
if let name {
264264
task =
265-
name.utf8CString.withUnsafeBufferPointer { nameBytes in
265+
unsafe name.utf8CString.withUnsafeBufferPointer { nameBytes in
266266
${TASK_CREATE_FN}(
267267
flags: flags,
268268
initialSerialExecutor: builtinSerialExecutor,

stdlib/public/Synchronization/Atomics/AtomicLazyReference.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public struct AtomicLazyReference<Instance: AnyObject>: ~Copyable {
2525
@available(SwiftStdlib 6.0, *)
2626
@inlinable
2727
public init() {
28-
storage = unsafe Atomic<Unmanaged<Instance>?>(nil)
28+
unsafe storage = Atomic<Unmanaged<Instance>?>(nil)
2929
}
3030

3131
@inlinable

0 commit comments

Comments
 (0)