Skip to content

Commit 77e66bd

Browse files
authored
Merge pull request #1603 from ahoppen/fix-warnings
Fix build warnings
2 parents 6901514 + ae660e0 commit 77e66bd

22 files changed

+40
-78
lines changed

Sources/BuildSystemIntegration/BuildServerBuildSystem.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import BuildServerProtocol
14+
import Foundation
1415
import LanguageServerProtocol
1516
import LanguageServerProtocolJSONRPC
1617
import SKLogging
@@ -26,13 +27,6 @@ import var TSCBasic.localFileSystem
2627
import func TSCBasic.lookupExecutablePath
2728
import func TSCBasic.resolveSymlinks
2829

29-
#if canImport(Darwin)
30-
import Foundation
31-
#else
32-
// FIMXE: (async-workaround) @preconcurrency needed because Pipe is not marked as Sendable on Linux rdar://132378792
33-
@preconcurrency import Foundation
34-
#endif
35-
3630
enum BuildServerTestError: Error {
3731
case executableNotFound(String)
3832
}

Sources/Diagnose/DiagnoseCommand.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ package struct DiagnoseCommand: AsyncParsableCommand {
213213
#if os(macOS)
214214
reportProgress(.collectingLogMessages(progress: 0), message: "Collecting log messages")
215215
let outputFileUrl = bundlePath.appendingPathComponent("log.txt")
216-
FileManager.default.createFile(atPath: outputFileUrl.path, contents: nil)
216+
guard FileManager.default.createFile(atPath: outputFileUrl.path, contents: nil) else {
217+
throw ReductionError("Failed to create log.txt")
218+
}
217219
let fileHandle = try FileHandle(forWritingTo: outputFileUrl)
218220
var bytesCollected = 0
219221
// 50 MB is an average log size collected by sourcekit-lsp diagnose.
@@ -304,7 +306,9 @@ package struct DiagnoseCommand: AsyncParsableCommand {
304306
@MainActor
305307
private func addSwiftVersion(toBundle bundlePath: URL) async throws {
306308
let outputFileUrl = bundlePath.appendingPathComponent("swift-versions.txt")
307-
FileManager.default.createFile(atPath: outputFileUrl.path, contents: nil)
309+
guard FileManager.default.createFile(atPath: outputFileUrl.path, contents: nil) else {
310+
throw ReductionError("Failed to create file at \(outputFileUrl)")
311+
}
308312
let fileHandle = try FileHandle(forWritingTo: outputFileUrl)
309313

310314
let toolchains = try await toolchainRegistry.toolchains

Sources/Diagnose/IndexCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,4 @@ fileprivate extension SourceKitLSPServer {
121121
}
122122
}
123123

124-
extension ExperimentalFeature: ExpressibleByArgument {}
124+
extension ExperimentalFeature: ArgumentParser.ExpressibleByArgument {}

Sources/Diagnose/MergeSwiftFiles.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ extension RequestInfo {
2323
progressUpdate: (_ progress: Double, _ message: String) -> Void
2424
) async throws -> RequestInfo? {
2525
let swiftFilePaths = compilerArgs.filter { $0.hasSuffix(".swift") }
26-
let mergedFile = try swiftFilePaths.map { try String(contentsOfFile: $0) }.joined(separator: "\n\n\n\n")
26+
let mergedFile = try swiftFilePaths.map { try String(contentsOfFile: $0, encoding: .utf8) }
27+
.joined(separator: "\n\n\n\n")
2728

2829
progressUpdate(0, "Merging all .swift files into a single file")
2930

Sources/Diagnose/ReduceCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ package struct ReduceCommand: AsyncParsableCommand {
7878

7979
let progressBar = PercentProgressAnimation(stream: stderrStreamConcurrencySafe, header: "Reducing sourcekitd issue")
8080

81-
let request = try String(contentsOfFile: sourcekitdRequestPath)
81+
let request = try String(contentsOfFile: sourcekitdRequestPath, encoding: .utf8)
8282
let requestInfo = try RequestInfo(request: request)
8383

8484
let executor = OutOfProcessSourceKitRequestExecutor(

Sources/Diagnose/RequestInfo.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ package struct RequestInfo: Sendable {
104104

105105
self.requestTemplate = requestTemplate
106106

107-
fileContents = try String(contentsOf: URL(fileURLWithPath: sourceFilePath))
107+
fileContents = try String(contentsOf: URL(fileURLWithPath: sourceFilePath), encoding: .utf8)
108108
}
109109

110110
/// Create a `RequestInfo` that is used to reduce a `swift-frontend issue`
@@ -126,7 +126,7 @@ package struct RequestInfo: Sendable {
126126
guard let fileList = iterator.next() else {
127127
throw ReductionError("Expected file path after -filelist command line argument")
128128
}
129-
frontendArgsWithFilelistInlined += try String(contentsOfFile: fileList)
129+
frontendArgsWithFilelistInlined += try String(contentsOfFile: fileList, encoding: .utf8)
130130
.split(separator: "\n")
131131
.map { String($0) }
132132
default:

Sources/Diagnose/RunSourcekitdRequestCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ package struct RunSourceKitdRequestCommand: AsyncParsableCommand {
4242
package init() {}
4343

4444
package func run() async throws {
45-
var requestString = try String(contentsOf: URL(fileURLWithPath: sourcekitdRequestPath))
45+
var requestString = try String(contentsOf: URL(fileURLWithPath: sourcekitdRequestPath), encoding: .utf8)
4646

4747
let installPath = try AbsolutePath(validating: Bundle.main.bundlePath)
4848
let sourcekitdPath =

Sources/SKLogging/NonDarwinLogging.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import SwiftExtensions
1515
#if canImport(Darwin)
1616
import Foundation
1717
#else
18-
// FIMXE: (async-workaround) @preconcurrency needed because DateFormatter and stderr are not marked as Sendable on Linux
19-
// rdar://125578486, rdar://132378589
18+
// TODO: @preconcurrency needed because stderr is not sendable on Linux https://github.com/swiftlang/swift/issues/75601
2019
@preconcurrency import Foundation
2120
#endif
2221

Sources/SKLogging/SetGlobalLogFileHandler.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import RegexBuilder
1515
#if canImport(Darwin)
1616
import Foundation
1717
#else
18-
// FIMXE: (async-workaround) @preconcurrency needed because DateFormatter and stderr are not marked as Sendable on Linux
19-
// rdar://125578486, rdar://132378589
18+
// TODO: @preconcurrency needed because stderr is not sendable on Linux https://github.com/swiftlang/swift/issues/75601
2019
@preconcurrency import Foundation
2120
#endif
2221

Sources/SKSupport/DocumentURI+CustomLogStringConvertible.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ extension DocumentURI {
2121
return "<DocumentURI length=\(description.count) hash=\(description.hashForLogging)>"
2222
}
2323
}
24-
extension DocumentURI: CustomLogStringConvertible {}
24+
extension DocumentURI: SKLogging.CustomLogStringConvertible {}

0 commit comments

Comments
 (0)