Skip to content

Commit 9d52204

Browse files
authored
Merge pull request #3052 from ahoppen/merge-main-6.2-2025-04-10
Merge `main` into `release/6.2`
2 parents 71e6dc8 + b9df7d0 commit 9d52204

File tree

7 files changed

+41
-11
lines changed

7 files changed

+41
-11
lines changed

.github/workflows/pull_request.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ on:
44
pull_request:
55
types: [opened, reopened, synchronize]
66

7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
711
jobs:
812
tests:
913
name: Test
1014
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
11-
with:
12-
linux_exclude_swift_versions: "[{\"swift_version\": \"5.8\"}]"
1315
soundness:
1416
name: Soundness
1517
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main

BUILD.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ swift_syntax_library(
219219
":SwiftSyntax509",
220220
":SwiftSyntax510",
221221
":SwiftSyntax600",
222+
":SwiftSyntax601",
223+
":SwiftSyntax602",
222224
":_SwiftSyntaxCShims",
223225
],
224226
)
@@ -251,6 +253,13 @@ swift_syntax_library(
251253
],
252254
)
253255

256+
swift_syntax_library(
257+
name = "SwiftSyntax602",
258+
srcs = glob(["Sources/VersionMarkerModules/SwiftSyntax602/**/*.swift"]),
259+
deps = [
260+
],
261+
)
262+
254263
swift_syntax_library(
255264
name = "SwiftSyntaxBuilder",
256265
deps = [
@@ -376,6 +385,7 @@ cc_library(
376385

377386
cc_library(
378387
name = "_SwiftSyntaxCShims",
388+
srcs = glob(["Sources/_SwiftSyntaxCShims/*.c"]),
379389
hdrs = glob(["Sources/_SwiftSyntaxCShims/include/*.h"]),
380390
includes = ["Sources/_SwiftSyntaxCShims/include"],
381391
tags = ["swift_module=_SwiftSyntaxCShims"],

Package.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ let package = Package(
210210

211211
.target(
212212
name: "SwiftSyntax",
213-
dependencies: ["_SwiftSyntaxCShims", "SwiftSyntax509", "SwiftSyntax510", "SwiftSyntax600"],
213+
dependencies: [
214+
"_SwiftSyntaxCShims", "SwiftSyntax509", "SwiftSyntax510", "SwiftSyntax600", "SwiftSyntax601", "SwiftSyntax602",
215+
],
214216
exclude: ["CMakeLists.txt"],
215217
swiftSettings: swiftSyntaxSwiftSettings
216218
),

Sources/SwiftDiagnostics/DiagnosticsFormatter.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,13 @@ public struct DiagnosticsFormatter {
293293
)
294294
)
295295

296-
// If the line did not end with \n (e.g. the last line), append it manually
297-
if annotatedSource.last != "\n" {
298-
annotatedSource.append("\n")
296+
// Remove any trailing newline and replace it; this may seem
297+
// counterintuitive, but if we're running within CMake and we let a
298+
// '\r\n' through, CMake will turn that into *two* newlines.
299+
if let last = annotatedSource.last, last.isNewline {
300+
annotatedSource.removeLast()
299301
}
302+
annotatedSource.append("\n")
300303

301304
let columnsWithDiagnostics = Set(
302305
annotatedLine.diagnostics.map {
@@ -331,8 +334,13 @@ public struct DiagnosticsFormatter {
331334
}
332335

333336
// Add suffix text.
334-
annotatedSource.append(annotatedLine.suffixText)
335-
if annotatedSource.last != "\n" {
337+
if !annotatedLine.suffixText.isEmpty {
338+
annotatedSource.append(annotatedLine.suffixText)
339+
340+
// See above for an explanation of why we do this
341+
if let last = annotatedSource.last, last.isNewline {
342+
annotatedSource.removeLast()
343+
}
336344
annotatedSource.append("\n")
337345
}
338346
}

Sources/SwiftOperators/OperatorTable+Folding.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ extension OperatorTable {
141141
if let unsafeExpr = lhs.as(UnsafeExprSyntax.self) {
142142
return ExprSyntax(
143143
UnsafeExprSyntax(
144-
leadingTrivia: unsafeExpr.leadingTrivia,
145144
unsafeExpr.unexpectedBeforeUnsafeKeyword,
146145
unsafeKeyword: unsafeExpr.unsafeKeyword,
147146
unsafeExpr.unexpectedBetweenUnsafeKeywordAndExpression,
@@ -150,8 +149,7 @@ extension OperatorTable {
150149
op: op,
151150
rhs: rhs
152151
),
153-
unsafeExpr.unexpectedAfterExpression,
154-
trailingTrivia: unsafeExpr.trailingTrivia
152+
unsafeExpr.unexpectedAfterExpression
155153
)
156154
)
157155
}

Sources/VersionMarkerModules/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ add_library(${SWIFTSYNTAX_TARGET_NAMESPACE}SwiftSyntax510 STATIC
1414
SwiftSyntax509/Empty.swift)
1515
add_library(${SWIFTSYNTAX_TARGET_NAMESPACE}SwiftSyntax600 STATIC
1616
SwiftSyntax509/Empty.swift)
17+
add_library(${SWIFTSYNTAX_TARGET_NAMESPACE}SwiftSyntax601 STATIC
18+
SwiftSyntax509/Empty.swift)
19+
add_library(${SWIFTSYNTAX_TARGET_NAMESPACE}SwiftSyntax602 STATIC
20+
SwiftSyntax509/Empty.swift)

Tests/SwiftOperatorsTest/OperatorTableTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,4 +435,10 @@ class OperatorPrecedenceTests: XCTestCase {
435435
}
436436

437437
}
438+
439+
func testTriviaAroundUnsafeExpr() throws {
440+
let original = ExprSyntax("/*leading*/ unsafe a /*trailing*/ + b")
441+
let folded = try OperatorTable.standardOperators.foldAll(original)
442+
XCTAssertEqual(original.description, folded.description)
443+
}
438444
}

0 commit comments

Comments
 (0)