Skip to content

Commit 544cbae

Browse files
committed
Merge branch 'main' into merge-main-6.2-2025-04-10
2 parents 340f840 + 7ba88aa commit 544cbae

File tree

8 files changed

+74
-13
lines changed

8 files changed

+74
-13
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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ swift_syntax_library(
219219
":SwiftSyntax509",
220220
":SwiftSyntax510",
221221
":SwiftSyntax600",
222+
":SwiftSyntax601",
223+
":SwiftSyntax602",
224+
":SwiftSyntax603",
222225
":_SwiftSyntaxCShims",
223226
],
224227
)
@@ -251,6 +254,20 @@ swift_syntax_library(
251254
],
252255
)
253256

257+
swift_syntax_library(
258+
name = "SwiftSyntax602",
259+
srcs = glob(["Sources/VersionMarkerModules/SwiftSyntax602/**/*.swift"]),
260+
deps = [
261+
],
262+
)
263+
264+
swift_syntax_library(
265+
name = "SwiftSyntax603",
266+
srcs = glob(["Sources/VersionMarkerModules/SwiftSyntax603/**/*.swift"]),
267+
deps = [
268+
],
269+
)
270+
254271
swift_syntax_library(
255272
name = "SwiftSyntaxBuilder",
256273
deps = [
@@ -376,6 +393,7 @@ cc_library(
376393

377394
cc_library(
378395
name = "_SwiftSyntaxCShims",
396+
srcs = glob(["Sources/_SwiftSyntaxCShims/*.c"]),
379397
hdrs = glob(["Sources/_SwiftSyntaxCShims/include/*.h"]),
380398
includes = ["Sources/_SwiftSyntaxCShims/include"],
381399
tags = ["swift_module=_SwiftSyntaxCShims"],

Package.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,10 @@ 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+
"SwiftSyntax603",
216+
],
214217
exclude: ["CMakeLists.txt"],
215218
swiftSettings: swiftSyntaxSwiftSettings
216219
),
@@ -248,6 +251,11 @@ let package = Package(
248251
path: "Sources/VersionMarkerModules/SwiftSyntax602"
249252
),
250253

254+
.target(
255+
name: "SwiftSyntax603",
256+
path: "Sources/VersionMarkerModules/SwiftSyntax603"
257+
),
258+
251259
// MARK: SwiftSyntaxBuilder
252260

253261
.target(

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: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
add_library(${SWIFTSYNTAX_TARGET_NAMESPACE}SwiftSyntax509 STATIC
1212
SwiftSyntax509/Empty.swift)
1313
add_library(${SWIFTSYNTAX_TARGET_NAMESPACE}SwiftSyntax510 STATIC
14-
SwiftSyntax509/Empty.swift)
14+
SwiftSyntax510/Empty.swift)
1515
add_library(${SWIFTSYNTAX_TARGET_NAMESPACE}SwiftSyntax600 STATIC
16-
SwiftSyntax509/Empty.swift)
16+
SwiftSyntax600/Empty.swift)
17+
add_library(${SWIFTSYNTAX_TARGET_NAMESPACE}SwiftSyntax601 STATIC
18+
SwiftSyntax601/Empty.swift)
19+
add_library(${SWIFTSYNTAX_TARGET_NAMESPACE}SwiftSyntax602 STATIC
20+
SwiftSyntax602/Empty.swift)
21+
add_library(${SWIFTSYNTAX_TARGET_NAMESPACE}SwiftSyntax603 STATIC
22+
SwiftSyntax603/Empty.swift)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
// The SwiftSyntax603 module is intentionally empty.
14+
// It serves as an indicator which version of swift-syntax a package is building against.
15+
// See the 'Macro Versioning.md' document for more details.

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)