Skip to content

NFC: Resolve some Sendable-related warnings #7822

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
Jul 27, 2024
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
5 changes: 2 additions & 3 deletions Sources/Basics/Netrc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import Foundation

/// Representation of Netrc configuration
public struct Netrc {
public struct Netrc: Sendable {
/// Representation of `machine` connection settings & `default` connection settings.
/// If `default` connection settings present, they will be last element.
public let machines: [Machine]
Expand All @@ -37,7 +37,7 @@ public struct Netrc {
}

/// Representation of connection settings
public struct Machine: Equatable {
public struct Machine: Equatable, Sendable {
public let name: String
public let login: String
public let password: String
Expand Down Expand Up @@ -147,7 +147,6 @@ public enum NetrcError: Error, Equatable {
}

private enum RegexUtil {
@frozen
fileprivate enum Token: String, CaseIterable {
case machine, login, password, account, macdef, `default`

Expand Down
10 changes: 7 additions & 3 deletions Sources/_InternalTestSupport/MockArchiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@
import Basics

package final class MockArchiver: Archiver {
package typealias ExtractionHandler = (
package typealias ExtractionHandler = @Sendable (
MockArchiver,
AbsolutePath,
AbsolutePath,
(Result<Void, Error>) -> Void
) throws -> Void
package typealias CompressionHandler = (
package typealias CompressionHandler = @Sendable (
MockArchiver,
AbsolutePath,
AbsolutePath,
(Result<Void, Error>) -> Void
) throws -> Void
package typealias ValidationHandler = (MockArchiver, AbsolutePath, (Result<Bool, Error>) -> Void) throws -> Void
package typealias ValidationHandler = @Sendable (
MockArchiver,
AbsolutePath,
(Result<Bool, Error>) -> Void
) throws -> Void

package struct Extraction: Equatable {
public let archivePath: AbsolutePath
Expand Down
2 changes: 2 additions & 0 deletions Tests/BasicsTests/CancellatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ final class CancellatorTests: XCTestCase {
struct Worker {
func work() {}

@Sendable
func cancel() {
Thread.sleep(forTimeInterval: 5)
}
Expand Down Expand Up @@ -391,6 +392,7 @@ fileprivate struct Worker {
return self.semaphore.wait(timeout: deadline)
}

@Sendable
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should try enabling InferSendableFromCaptures instead of these explicit attributes in few places including properties.

Copy link
Contributor

Choose a reason for hiding this comment

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

cc @MaxDesiatov, we can do that without experimental flags too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How would you do that without experimental flags? Does Swift 6 language mode include support for that?

Copy link
Contributor

Choose a reason for hiding this comment

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

It’s an upcoming feature flag.

func cancel() {
print("\(self.name) cancel")
self.semaphore.signal()
Expand Down
1 change: 1 addition & 0 deletions Tests/CommandsTests/PackageRegistryCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ final class PackageRegistryCommandTests: CommandsTestCase {
)
}

@Sendable
func validateManifest(
manifestFile: String,
in archivePath: AbsolutePath,
Expand Down
2 changes: 1 addition & 1 deletion Tests/CommandsTests/TestCommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ final class TestCommandTests: CommandsTestCase {
}

try await fixture(name: "Miscellaneous/SkipTests") { fixturePath in
let (stdout, stderr) = try await SwiftPM.Test.execute(["--skip", "Tests"], packagePath: fixturePath)
let (stdout, _) = try await SwiftPM.Test.execute(["--skip", "Tests"], packagePath: fixturePath)
// in "swift test" test output goes to stdout
XCTAssertNoMatch(stdout, .contains("testExample1"))
XCTAssertNoMatch(stdout, .contains("testExample2"))
Expand Down