Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

import PackageDescription

// Used only for environment variables, does not make its way
// into the product code.
import class Foundation.ProcessInfo

let swiftAtomics: PackageDescription.Target.Dependency = .product(name: "Atomics", package: "swift-atomics")
let swiftCollections: PackageDescription.Target.Dependency = .product(name: "DequeModule", package: "swift-collections")
let swiftSystem: PackageDescription.Target.Dependency = .product(
Expand All @@ -23,16 +27,21 @@ let swiftSystem: PackageDescription.Target.Dependency = .product(
condition: .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .linux, .android])
)

let strictConcurrencySettings: [SwiftSetting] = [
.enableUpcomingFeature("StrictConcurrency"),
.enableUpcomingFeature("InferSendableFromCaptures"),
]
let strictConcurrencySettings: [SwiftSetting] = {
var initialSettings: [SwiftSetting] = []
initialSettings.append(contentsOf: [
.enableUpcomingFeature("StrictConcurrency"),
.enableUpcomingFeature("InferSendableFromCaptures"),
])

#if compiler(>=6.0)
if ProcessInfo.processInfo.environment["CI"] != nil {
initialSettings.append(.unsafeFlags(["-require-explicit-sendable", "-warnings-as-errors"]))
Comment thread
Lukasa marked this conversation as resolved.
}
#endif

// Add these Swift settings to targets that need to be validated
// for strict concurrency.
let diagnosticSettings: [SwiftSetting] = [
.unsafeFlags(["-require-explicit-sendable", "-warnings-as-errors"])
]
return initialSettings
}()

// This doesn't work when cross-compiling: the privacy manifest will be included in the Bundle and
// Foundation will be linked. This is, however, strictly better than unconditionally adding the
Expand Down Expand Up @@ -81,7 +90,8 @@ let package = Package(
swiftSettings: strictConcurrencySettings
),
.target(
name: "_NIOBase64"
name: "_NIOBase64",
swiftSettings: strictConcurrencySettings
),
.target(
name: "NIOEmbedded",
Expand Down
2 changes: 1 addition & 1 deletion Sources/_NIOBase64/Base64.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public enum Base64Error: Error {
}

@usableFromInline
internal struct Base64 {
internal enum Base64: Sendable {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this to be Sendable even if it is just a namespace?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Because it's @usableFromInline, -require-explicit-sendable applies to it, and that flag does not notice that you can't actually form a value to it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More broadly, -require-explicit-sendable forces our hand for everything. "Need" doesn't really come into it: we have to mark anything it wants us to mark.


@inlinable
static func encode<Buffer: Collection>(bytes: Buffer) -> String where Buffer.Element == UInt8 {
Expand Down