From d4547ec74c55c1f9274c51c653a2af284b282aeb Mon Sep 17 00:00:00 2001 From: Allan Shortlidge Date: Mon, 23 Feb 2026 09:29:46 -0800 Subject: [PATCH] stdlib: Fix compiler warnings in Concurrency, Cxx, and RuntimeModule - Remove spurious `unsafe` on non-unsafe calls in TaskCancellation.swift and UnsafeCxxIterators.swift - Change `var fd` to `let fd` in ImageSource.swift since it is never mutated --- stdlib/public/Concurrency/TaskCancellation.swift | 2 +- stdlib/public/Cxx/UnsafeCxxIterators.swift | 2 +- stdlib/public/RuntimeModule/ImageSource.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/public/Concurrency/TaskCancellation.swift b/stdlib/public/Concurrency/TaskCancellation.swift index 5d887efe3e954..cc9ab9d2db007 100644 --- a/stdlib/public/Concurrency/TaskCancellation.swift +++ b/stdlib/public/Concurrency/TaskCancellation.swift @@ -225,7 +225,7 @@ extension Task { // This is @available(SwiftStdlib 6.4, *) but can't use SwiftStdlib in transparent function if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999, *) { let ignoreTaskCancellationShield: UInt64 = 0x1 - return unsafe _taskIsCancelledWithFlags(_task, flags: ignoreTaskCancellationShield) + return _taskIsCancelledWithFlags(_task, flags: ignoreTaskCancellationShield) } else { return _taskIsCancelled(_task) } diff --git a/stdlib/public/Cxx/UnsafeCxxIterators.swift b/stdlib/public/Cxx/UnsafeCxxIterators.swift index 216a778ae75c8..db4f71b1d211b 100644 --- a/stdlib/public/Cxx/UnsafeCxxIterators.swift +++ b/stdlib/public/Cxx/UnsafeCxxIterators.swift @@ -85,7 +85,7 @@ extension Optional: @unsafe UnsafeCxxInputIterator where Wrapped: UnsafeCxxInput guard let value = self else { fatalError("Could not dereference nullptr") } - return unsafe value.__operatorStar() + return value.__operatorStar() } } diff --git a/stdlib/public/RuntimeModule/ImageSource.swift b/stdlib/public/RuntimeModule/ImageSource.swift index 77daca74b9840..fd781cb4de7c2 100644 --- a/stdlib/public/RuntimeModule/ImageSource.swift +++ b/stdlib/public/RuntimeModule/ImageSource.swift @@ -183,7 +183,7 @@ struct ImageSource: CustomStringConvertible { self.init(mapped: UnsafeRawBufferPointer( start: base, count: size)) #else - var fd = _swift_open(path, O_RDONLY, 0) + let fd = _swift_open(path, O_RDONLY, 0) if fd < 0 { throw ImageSourceError.posixError(_swift_get_errno()) }