Skip to content

Commit e9bd3c8

Browse files
authored
Merge pull request #1034 from swiftlang/automerge/merge-main-2025-06-16_09-01
Merge `main` into `release/6.2`
2 parents 2a8349e + acf0aa1 commit e9bd3c8

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,6 +2737,13 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
27372737
return .visitChildren
27382738
}
27392739

2740+
override func visit(_ node: BorrowExprSyntax) -> SyntaxVisitorContinueKind {
2741+
// The `borrow` keyword cannot be separated from the following token or it will be parsed as
2742+
// an identifier.
2743+
after(node.borrowKeyword, tokens: .space)
2744+
return .visitChildren
2745+
}
2746+
27402747
override func visit(_ node: ConsumeExprSyntax) -> SyntaxVisitorContinueKind {
27412748
// The `consume` keyword cannot be separated from the following token or it will be parsed as
27422749
// an identifier.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
final class BorrowExprTests: PrettyPrintTestCase {
14+
func testBorrow() {
15+
assertPrettyPrintEqual(
16+
input: """
17+
@lifetime(borrow self)
18+
init() {}
19+
""",
20+
expected: """
21+
@lifetime(
22+
borrow self)
23+
init() {}
24+
25+
""",
26+
linelength: 21
27+
)
28+
}
29+
}

0 commit comments

Comments
 (0)