fix remaining warnings & enable -warnings-as-errors in CI (#3000)

### Motivation:

Warnings are annoying.

### Modifications:

- Remove unnecessary use of `Foundation.Thread` which isn't Sendable.
- Remove now unnecessary `@retroactive`s.
- Enable `-warnings-as-errors` in CI

### Result:

- Warnings can't sneak in as easily anymore
- No more warnings left in `swift-nio`

```
$ rm -rf .build/arm64-apple-macosx/ && swift build --build-tests -Xswiftc -warnings-as-errors > /dev/null
echo $?
$ echo $?
0
```

Co-authored-by: Cory Benfield <lukasa@apple.com>
This commit is contained in:
Johannes WeissandCory Benfield authored and GitHub committed 2024-11-26 16:02:36 +00:00
1 parent d2cc4d7f94
commit 49b9d9725e
6 files changed
+17 -34

No files matched your search

+2 -2
View File
@@ -14,8 +14,8 @@ jobs:
with:
linux_5_9_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
cxx-interop:
@@ -377,15 +377,9 @@ extension ByteBufferAllocator {
}
// MARK: - Conformances
#if compiler(>=6.0)
extension ByteBufferView: @retroactive ContiguousBytes {}
extension ByteBufferView: @retroactive DataProtocol {}
extension ByteBufferView: @retroactive MutableDataProtocol {}
#else
extension ByteBufferView: ContiguousBytes {}
extension ByteBufferView: DataProtocol {}
extension ByteBufferView: MutableDataProtocol {}
#endif
extension ByteBufferView {
public typealias Regions = CollectionOfOne<ByteBufferView>
@@ -224,7 +224,7 @@ class EchoServerClientTest: XCTestCase {
try withTemporaryUnixDomainSocketPathName { udsPath in
// Bootstrap should not overwrite an existing file unless it is a socket
FileManager.default.createFile(atPath: udsPath, contents: nil, attributes: nil)
_ = FileManager.default.createFile(atPath: udsPath, contents: nil, attributes: nil)
let bootstrap = ServerBootstrap(group: group)
XCTAssertThrowsError(
+11 -18
View File
@@ -78,18 +78,15 @@ class NIOThreadPoolTest: XCTestCase {
// The lock here is arguably redundant with the dispatchgroup, but let's make
// this test thread-safe even if I screw up.
let lock = NIOLock()
let threadOne: NIOLockedValueBox<Thread?> = NIOLockedValueBox(Thread?.none)
let threadTwo: NIOLockedValueBox<Thread?> = NIOLockedValueBox(Thread?.none)
let threadOne: NIOLockedValueBox<NIOThread?> = NIOLockedValueBox(NIOThread?.none)
let threadTwo: NIOLockedValueBox<NIOThread?> = NIOLockedValueBox(NIOThread?.none)
completionGroup.enter()
pool.submit { s in
precondition(s == .active)
lock.withLock { () -> Void in
threadOne.withLockedValue { threadOne in
XCTAssertEqual(threadOne, nil)
threadOne = Thread.current
}
threadOne.withLockedValue { threadOne in
XCTAssertEqual(threadOne, nil)
threadOne = NIOThread.current
}
completionGroup.leave()
}
@@ -99,22 +96,18 @@ class NIOThreadPoolTest: XCTestCase {
completionGroup.enter()
pool.submit { s in
precondition(s == .active)
lock.withLock { () -> Void in
threadTwo.withLockedValue { threadTwo in
XCTAssertEqual(threadTwo, nil)
threadTwo = Thread.current
}
threadTwo.withLockedValue { threadTwo in
XCTAssertEqual(threadTwo, nil)
threadTwo = NIOThread.current
}
completionGroup.leave()
}
completionGroup.wait()
lock.withLock { () -> Void in
XCTAssertNotNil(threadOne)
XCTAssertNotNil(threadTwo)
XCTAssertEqual(threadOne.withLockedValue { $0 }, threadTwo.withLockedValue { $0 })
}
XCTAssertNotNil(threadOne.withLockedValue { $0 })
XCTAssertNotNil(threadTwo.withLockedValue { $0 })
XCTAssertEqual(threadOne.withLockedValue { $0 }, threadTwo.withLockedValue { $0 })
}
func testAsyncThreadPool() async throws {
+1 -5
View File
@@ -59,16 +59,12 @@ final class SALEventLoopTests: XCTestCase, SALTest {
}
// Now execute 10 tasks.
var i = 0
for _ in 0..<10 {
thisLoop.execute {
i &+= 1
}
thisLoop.execute {}
}
// Now enqueue a "last" task.
thisLoop.execute {
i &+= 1
promise.succeed(())
}
+2 -2
View File
@@ -127,7 +127,7 @@ func withTemporaryUnixDomainSocketPathName<T>(
shortEnoughPath = path
restoreSavedCWD = false
} catch SocketAddressError.unixDomainSocketPathTooLong {
FileManager.default.changeCurrentDirectoryPath(
_ = FileManager.default.changeCurrentDirectoryPath(
URL(fileURLWithPath: path).deletingLastPathComponent().absoluteString
)
shortEnoughPath = URL(fileURLWithPath: path).lastPathComponent
@@ -141,7 +141,7 @@ func withTemporaryUnixDomainSocketPathName<T>(
try? FileManager.default.removeItem(atPath: path)
}
if restoreSavedCWD {
FileManager.default.changeCurrentDirectoryPath(saveCurrentDirectory)
_ = FileManager.default.changeCurrentDirectoryPath(saveCurrentDirectory)
}
}
return try body(shortEnoughPath)