From 54bc6b344341e0dade4c00aaa0a62f385e122239 Mon Sep 17 00:00:00 2001 From: Rafael Cepeda Date: Wed, 6 Aug 2025 19:58:16 +0100 Subject: [PATCH 1/3] Fixed warnings when compiling with -require-explicit-sendable. --- .gitignore | 2 ++ Package.swift | 3 ++- Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift | 6 ++++++ Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift | 6 ++++++ Sources/HTTPServer/HTTPServer.swift | 2 +- Sources/HTTPServer/HTTPServerClosureRequestHandler.swift | 2 +- Sources/Middleware/MiddlewareBuilder.swift | 2 +- Sources/Middleware/MiddlewareChain.swift | 3 +++ 8 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index a3ea0ac..dc1a05b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ DerivedData/ .netrc Package.resolved .swiftpm/xcode/ +.vscode +.swift-version diff --git a/Package.swift b/Package.swift index 0956d4d..15be244 100644 --- a/Package.swift +++ b/Package.swift @@ -1,10 +1,11 @@ -// swift-tools-version: 6.1 +// swift-tools-version: 6.0 import PackageDescription let extraSettings: [SwiftSetting] = [ .enableExperimentalFeature("SuppressedAssociatedTypes"), .enableExperimentalFeature("LifetimeDependence"), + .enableExperimentalFeature("NonescapableTypes"), .enableUpcomingFeature("LifetimeDependence"), .enableUpcomingFeature("NonisolatedNonsendingByDefault"), .enableUpcomingFeature("InferIsolatedConformances"), diff --git a/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift b/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift index 77b3564..8eb3234 100644 --- a/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift +++ b/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift @@ -114,3 +114,9 @@ public struct HTTPRequestConcludingAsyncReader: ConcludingAsyncReader { return (result, partsReader.trailers) } } + +@available(*, unavailable) +extension HTTPRequestConcludingAsyncReader: Sendable { } + +@available(*, unavailable) +extension HTTPRequestConcludingAsyncReader.RequestBodyAsyncReader: Sendable { } diff --git a/Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift b/Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift index 8f5c404..7933611 100644 --- a/Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift +++ b/Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift @@ -99,3 +99,9 @@ public struct HTTPResponseConcludingAsyncWriter: ConcludingAsyncWriter, ~Copyabl return result } } + +@available(*, unavailable) +extension HTTPResponseConcludingAsyncWriter: Sendable { } + +@available(*, unavailable) +extension HTTPResponseConcludingAsyncWriter.ResponseBodyAsyncWriter: Sendable { } diff --git a/Sources/HTTPServer/HTTPServer.swift b/Sources/HTTPServer/HTTPServer.swift index 0cc8e36..e9bc735 100644 --- a/Sources/HTTPServer/HTTPServer.swift +++ b/Sources/HTTPServer/HTTPServer.swift @@ -59,7 +59,7 @@ import SwiftASN1 /// } /// } /// ``` -public final class Server { +public final class Server: Sendable { /// Starts an HTTP server with a closure-based request handler. /// /// This method provides a convenient way to start an HTTP server using a closure to handle incoming requests. diff --git a/Sources/HTTPServer/HTTPServerClosureRequestHandler.swift b/Sources/HTTPServer/HTTPServerClosureRequestHandler.swift index 0c68093..358817a 100644 --- a/Sources/HTTPServer/HTTPServerClosureRequestHandler.swift +++ b/Sources/HTTPServer/HTTPServerClosureRequestHandler.swift @@ -23,7 +23,7 @@ public import HTTPTypes /// } /// } /// ``` -public struct HTTPServerClosureRequestHandler: HTTPServerRequestHandler { +public struct HTTPServerClosureRequestHandler: HTTPServerRequestHandler, Sendable { /// The underlying closure that handles HTTP requests private let _handler: @Sendable ( diff --git a/Sources/Middleware/MiddlewareBuilder.swift b/Sources/Middleware/MiddlewareBuilder.swift index a42871d..169ac3d 100644 --- a/Sources/Middleware/MiddlewareBuilder.swift +++ b/Sources/Middleware/MiddlewareBuilder.swift @@ -21,7 +21,7 @@ /// } /// ``` @resultBuilder -public struct MiddlewareChainBuilder { +public struct MiddlewareChainBuilder: Sendable { /// Builds a middleware chain from a single middleware component. /// /// This is the base case for the result builder pattern, handling a single middleware. diff --git a/Sources/Middleware/MiddlewareChain.swift b/Sources/Middleware/MiddlewareChain.swift index b215c3c..671ca07 100644 --- a/Sources/Middleware/MiddlewareChain.swift +++ b/Sources/Middleware/MiddlewareChain.swift @@ -56,3 +56,6 @@ public struct MiddlewareChain: Middleware { try await middlewareFunc(input, next) } } + +@available(*, unavailable) +extension MiddlewareChain: Sendable { } \ No newline at end of file From f01baca1f67213b47b5d135e206a6d9a68f1f787 Mon Sep 17 00:00:00 2001 From: Rafael Cepeda Date: Wed, 6 Aug 2025 20:00:41 +0100 Subject: [PATCH 2/3] Reverted change about swift tools. --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 15be244..4b1caa5 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 6.0 +// swift-tools-version: 6.1 import PackageDescription From 27e9c96f06746cac78ebd27a0edb681e1f0a6f74 Mon Sep 17 00:00:00 2001 From: Rafael Cepeda Date: Wed, 29 Oct 2025 16:59:09 +0000 Subject: [PATCH 3/3] Removed unncessary conformance restrictions. --- Package.swift | 3 ++- Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift | 6 ------ Sources/Middleware/MiddlewareChain.swift | 3 --- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Package.swift b/Package.swift index 601e900..4794ae2 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,8 @@ let extraSettings: [SwiftSetting] = [ .enableUpcomingFeature("InferIsolatedConformances"), .enableUpcomingFeature("ExistentialAny"), .enableUpcomingFeature("MemberImportVisibility"), - .enableUpcomingFeature("InternalImportsByDefault") + .enableUpcomingFeature("InternalImportsByDefault"), + .unsafeFlags(["-Xfrontend", "-require-explicit-sendable", "-warnings-as-errors"]) ] let package = Package( diff --git a/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift b/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift index 19faffc..c38a32b 100644 --- a/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift +++ b/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift @@ -157,9 +157,3 @@ extension Optional { return result } } - -@available(*, unavailable) -extension HTTPRequestConcludingAsyncReader: Sendable { } - -@available(*, unavailable) -extension HTTPRequestConcludingAsyncReader.RequestBodyAsyncReader: Sendable { } diff --git a/Sources/Middleware/MiddlewareChain.swift b/Sources/Middleware/MiddlewareChain.swift index edfb0be..9ea9d4c 100644 --- a/Sources/Middleware/MiddlewareChain.swift +++ b/Sources/Middleware/MiddlewareChain.swift @@ -56,6 +56,3 @@ public struct MiddlewareChain: Middlewar try await middlewareFunc(input, next) } } - -@available(*, unavailable) -extension MiddlewareChain: Sendable { } \ No newline at end of file