Skip to content

Remove availability annotations for Span APIs #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 0 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

import PackageDescription

let availabilityMacro: SwiftSetting = .enableExperimentalFeature(
"AvailabilityMacro=SubprocessSpan: macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, visionOS 9999",
)

var dep: [Package.Dependency] = [
.package(
url: "https://github.com/apple/swift-system",
Expand Down Expand Up @@ -59,7 +55,6 @@ let package = Package(
.enableExperimentalFeature("NonescapableTypes"),
.enableExperimentalFeature("LifetimeDependence"),
.enableExperimentalFeature("Span"),
availabilityMacro,
]
),
.testTarget(
Expand All @@ -72,7 +67,6 @@ let package = Package(
],
swiftSettings: [
.enableExperimentalFeature("Span"),
availabilityMacro,
]
),

Expand Down
7 changes: 0 additions & 7 deletions Sources/Subprocess/API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
/// - output: The method to use for redirecting the standard output.
/// - error: The method to use for redirecting the standard error.
/// - Returns a CollectedResult containing the result of the run.
#if SubprocessSpan
@available(SubprocessSpan, *)
#endif
public func run<
Input: InputProtocol,
Output: OutputProtocol,
Expand Down Expand Up @@ -76,7 +73,6 @@ public func run<
/// - error: The method to use for redirecting the standard error.
/// - Returns a CollectedResult containing the result of the run.
#if SubprocessSpan
@available(SubprocessSpan, *)
public func run<
InputElement: BitwiseCopyable,
Output: OutputProtocol,
Expand Down Expand Up @@ -480,9 +476,6 @@ public func run<Result>(
/// - output: The method to use for redirecting the standard output.
/// - error: The method to use for redirecting the standard error.
/// - Returns a CollectedResult containing the result of the run.
#if SubprocessSpan
@available(SubprocessSpan, *)
#endif
public func run<
Input: InputProtocol,
Output: OutputProtocol,
Expand Down
3 changes: 0 additions & 3 deletions Sources/Subprocess/Buffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ extension AsyncBufferSequence.Buffer {

#if SubprocessSpan
// Access the storage backing this Buffer
#if SubprocessSpan
@available(SubprocessSpan, *)
#endif
public var bytes: RawSpan {
@lifetime(borrow self)
borrowing get {
Expand Down
1 change: 0 additions & 1 deletion Sources/Subprocess/IO/Input.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ public final actor StandardInputWriter: Sendable {
/// - Parameter span: The span to write
/// - Returns number of bytes written
#if SubprocessSpan
@available(SubprocessSpan, *)
public func write(_ span: borrowing RawSpan) async throws -> Int {
return try await self.diskIO.write(span)
}
Expand Down
6 changes: 0 additions & 6 deletions Sources/Subprocess/IO/Output.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public protocol OutputProtocol: Sendable, ~Copyable {

#if SubprocessSpan
/// Convert the output from span to expected output type
@available(SubprocessSpan, *)
func output(from span: RawSpan) throws -> OutputType
#endif

Expand Down Expand Up @@ -113,7 +112,6 @@ public struct StringOutput<Encoding: Unicode.Encoding>: OutputProtocol {
public let maxSize: Int

#if SubprocessSpan
@available(SubprocessSpan, *)
public func output(from span: RawSpan) throws -> String? {
// FIXME: Span to String
var array: [UInt8] = []
Expand Down Expand Up @@ -153,7 +151,6 @@ public struct BytesOutput: OutputProtocol {
}

#if SubprocessSpan
@available(SubprocessSpan, *)
public func output(from span: RawSpan) throws -> [UInt8] {
fatalError("Not implemented")
}
Expand Down Expand Up @@ -227,7 +224,6 @@ extension OutputProtocol where Self == BytesOutput {

// MARK: - Span Default Implementations
#if SubprocessSpan
@available(SubprocessSpan, *)
extension OutputProtocol {
public func output(from buffer: some Sequence<UInt8>) throws -> OutputType {
guard let rawBytes: UnsafeRawBufferPointer = buffer as? UnsafeRawBufferPointer else {
Expand Down Expand Up @@ -281,7 +277,6 @@ extension OutputProtocol where OutputType == Void {

#if SubprocessSpan
/// Convert the output from Data to expected output type
@available(SubprocessSpan, *)
public func output(from span: RawSpan) throws {
// noop
}
Expand All @@ -293,7 +288,6 @@ extension OutputProtocol where OutputType == Void {
}

#if SubprocessSpan
@available(SubprocessSpan, *)
extension OutputProtocol {
#if os(Windows)
internal func output(from data: [UInt8]) throws -> OutputType {
Expand Down
3 changes: 0 additions & 3 deletions Sources/Subprocess/Platforms/Subprocess+Linux.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ import _SubprocessCShims

// Linux specific implementations
extension Configuration {
#if SubprocessSpan
@available(SubprocessSpan, *)
#endif
internal func spawn(
withInput inputPipe: consuming CreatedPipe,
outputPipe: consuming CreatedPipe,
Expand Down
1 change: 0 additions & 1 deletion Sources/Subprocess/Platforms/Subprocess+Unix.swift
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ extension DispatchIO {

extension TrackedDispatchIO {
#if SubprocessSpan
@available(SubprocessSpan, *)
internal func write(
_ span: borrowing RawSpan
) async throws -> Int {
Expand Down
8 changes: 1 addition & 7 deletions Sources/Subprocess/Platforms/Subprocess+Windows.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ internal import Dispatch

// Windows specific implementation
extension Configuration {
#if SubprocessSpan
@available(SubprocessSpan, *)
#endif
internal func spawn(
withInput inputPipe: consuming CreatedPipe,
outputPipe: consuming CreatedPipe,
Expand Down Expand Up @@ -534,9 +531,7 @@ internal func monitorProcessTermination(
}

// MARK: - Subprocess Control
#if SubprocessSpan
@available(SubprocessSpan, *)
#endif

extension Execution {
/// Terminate the current subprocess with the given exit code
/// - Parameter exitCode: The exit code to use for the subprocess.
Expand Down Expand Up @@ -1165,7 +1160,6 @@ extension TrackedFileDescriptor {
}

#if SubprocessSpan
@available(SubprocessSpan, *)
internal func write(
_ span: borrowing RawSpan
) async throws -> Int {
Expand Down
19 changes: 1 addition & 18 deletions Sources/Subprocess/Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public struct ExecutionResult<Result> {

/// The result of a subprocess execution with its collected
/// standard output and standard error.
#if SubprocessSpan
@available(SubprocessSpan, *)
#endif
public struct CollectedResult<
Output: OutputProtocol,
Error: OutputProtocol
Expand All @@ -62,24 +59,13 @@ public struct CollectedResult<
}

// MARK: - CollectedResult Conformances
#if SubprocessSpan
@available(SubprocessSpan, *)
#endif

extension CollectedResult: Equatable where Output.OutputType: Equatable, Error.OutputType: Equatable {}

#if SubprocessSpan
@available(SubprocessSpan, *)
#endif
extension CollectedResult: Hashable where Output.OutputType: Hashable, Error.OutputType: Hashable {}

#if SubprocessSpan
@available(SubprocessSpan, *)
#endif
extension CollectedResult: Codable where Output.OutputType: Codable, Error.OutputType: Codable {}

#if SubprocessSpan
@available(SubprocessSpan, *)
#endif
extension CollectedResult: CustomStringConvertible
where Output.OutputType: CustomStringConvertible, Error.OutputType: CustomStringConvertible {
public var description: String {
Expand All @@ -94,9 +80,6 @@ where Output.OutputType: CustomStringConvertible, Error.OutputType: CustomString
}
}

#if SubprocessSpan
@available(SubprocessSpan, *)
#endif
extension CollectedResult: CustomDebugStringConvertible
where Output.OutputType: CustomDebugStringConvertible, Error.OutputType: CustomDebugStringConvertible {
public var debugDescription: String {
Expand Down
2 changes: 0 additions & 2 deletions Sources/Subprocess/Span+Subprocess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public func _overrideLifetime<
dependent
}

@available(SubprocessSpan, *)
extension Span where Element: BitwiseCopyable {

internal var _bytes: RawSpan {
Expand All @@ -55,7 +54,6 @@ extension Span where Element: BitwiseCopyable {
#if canImport(Glibc) || canImport(Bionic) || canImport(Musl)
internal import Dispatch

@available(SubprocessSpan, *)
extension DispatchData {
var bytes: RawSpan {
_read {
Expand Down
10 changes: 0 additions & 10 deletions Sources/Subprocess/SubprocessFoundation/Output+Foundation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ import FoundationEssentials
/// A concrete `Output` type for subprocesses that collects output
/// from the subprocess as `Data`. This option must be used with
/// the `run()` method that returns a `CollectedResult`
#if SubprocessSpan
@available(SubprocessSpan, *)
#endif
public struct DataOutput: OutputProtocol {
public typealias OutputType = Data
public let maxSize: Int
Expand All @@ -44,9 +41,6 @@ public struct DataOutput: OutputProtocol {
}
}

#if SubprocessSpan
@available(SubprocessSpan, *)
#endif
extension OutputProtocol where Self == DataOutput {
/// Create a `Subprocess` output that collects output as `Data`
/// up to 128kb.
Expand All @@ -61,9 +55,6 @@ extension OutputProtocol where Self == DataOutput {
}
}

#if SubprocessSpan
@available(SubprocessSpan, *)
#endif
extension Data {
/// Create a `Data` from `Buffer`
/// - Parameter buffer: buffer to copy from
Expand All @@ -74,7 +65,6 @@ extension Data {

// MARK: - Workarounds
#if SubprocessSpan
@available(SubprocessSpan, *)
extension OutputProtocol {
@_disfavoredOverload
public func output(from data: some DataProtocol) throws -> OutputType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import FoundationEssentials

internal import Dispatch

@available(SubprocessSpan, *)
extension Data {
init(_ s: borrowing RawSpan) {
self = s.withUnsafeBytes { Data($0) }
Expand All @@ -37,7 +36,6 @@ extension Data {
}
}

@available(SubprocessSpan, *)
extension DataProtocol {
var bytes: RawSpan {
_read {
Expand Down
9 changes: 0 additions & 9 deletions Tests/SubprocessTests/SubprocessTests+Darwin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ import Testing
@Suite(.serialized)
struct SubprocessDarwinTests {
@Test func testSubprocessPlatformOptionsProcessConfiguratorUpdateSpawnAttr() async throws {
guard #available(SubprocessSpan , *) else {
return
}
var platformOptions = PlatformOptions()
platformOptions.preSpawnProcessConfigurator = { spawnAttr, _ in
// Set POSIX_SPAWN_SETSID flag, which implies calls
Expand All @@ -50,9 +47,6 @@ struct SubprocessDarwinTests {
}

@Test func testSubprocessPlatformOptionsProcessConfiguratorUpdateFileAction() async throws {
guard #available(SubprocessSpan , *) else {
return
}
let intendedWorkingDir = FileManager.default.temporaryDirectory.path()
var platformOptions = PlatformOptions()
platformOptions.preSpawnProcessConfigurator = { _, fileAttr in
Expand All @@ -79,9 +73,6 @@ struct SubprocessDarwinTests {
}

@Test func testSuspendResumeProcess() async throws {
guard #available(SubprocessSpan , *) else {
return
}
_ = try await Subprocess.run(
// This will intentionally hang
.path("/bin/cat"),
Expand Down
3 changes: 0 additions & 3 deletions Tests/SubprocessTests/SubprocessTests+Linting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ struct SubprocessLintingTest {
)
)
func runLinter() async throws {
guard #available(SubprocessSpan , *) else {
return
}
// META: Use Subprocess to run `swift-format` on self
// to make sure it's properly linted
guard
Expand Down
Loading
Loading