Skip to content

Commit 8335b63

Browse files
committed
Enable UseLetInEveryBoundCaseVariable and update binding patterns.
1 parent 0db13de commit 8335b63

File tree

26 files changed

+71
-71
lines changed

26 files changed

+71
-71
lines changed

.swift-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"AmbiguousTrailingClosureOverload": false,
1313
"NoBlockComments": true,
1414
"OrderedImports": true,
15-
"UseLetInEveryBoundCaseVariable": false,
15+
"UseLetInEveryBoundCaseVariable": true,
1616
"UseSynthesizedInitializer": true
1717
}
1818
}

CodeGeneration/Sources/generate-swift-syntax/templates/swiftparser/ParserTokenSpecSetFile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let parserTokenSpecSetFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
3939

4040
for layoutNode in SYNTAX_NODES.compactMap(\.layoutNode) {
4141
for child in layoutNode.children {
42-
if case let .token(choices, _, _) = child.kind, choices.count > 1 {
42+
if case .token(let choices, _, _) = child.kind, choices.count > 1 {
4343
try! ExtensionDeclSyntax("extension \(layoutNode.kind.syntaxType)") {
4444
try EnumDeclSyntax(
4545
"""

Examples/Sources/MacroExamples/Implementation/Accessor/EnvironmentValueMacro.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public struct EnvironmentValueMacro: AccessorMacro {
2020
in context: some MacroExpansionContext
2121
) throws -> [AccessorDeclSyntax] {
2222
guard
23-
case let .argumentList(arguments) = node.arguments,
23+
case .argumentList(let arguments) = node.arguments,
2424
let argument = arguments.first
2525
else { return [] }
2626

Examples/Sources/MacroExamples/Implementation/ComplexMacros/OptionSetMacro.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ public struct OptionSetMacro {
8484
) -> (StructDeclSyntax, EnumDeclSyntax, TypeSyntax)? {
8585
// Determine the name of the options enum.
8686
let optionsEnumName: String
87-
if case let .argumentList(arguments) = attribute.arguments,
87+
if case .argumentList(let arguments) = attribute.arguments,
8888
let optionEnumNameArg = arguments.first(labeled: optionsEnumNameArgumentLabel)
8989
{
9090
// We have a options name; make sure it is a string literal.
9191
guard let stringLiteral = optionEnumNameArg.expression.as(StringLiteralExprSyntax.self),
9292
stringLiteral.segments.count == 1,
93-
case let .stringSegment(optionsEnumNameString)? = stringLiteral.segments.first
93+
case .stringSegment(let optionsEnumNameString)? = stringLiteral.segments.first
9494
else {
9595
if emitDiagnostics {
9696
context.diagnose(

Examples/Sources/MacroExamples/Implementation/Expression/WarningMacro.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public enum WarningMacro: ExpressionMacro {
2525
let stringLiteral = firstElement.expression
2626
.as(StringLiteralExprSyntax.self),
2727
stringLiteral.segments.count == 1,
28-
case let .stringSegment(messageString)? = stringLiteral.segments.first
28+
case .stringSegment(let messageString)? = stringLiteral.segments.first
2929
else {
3030
throw CustomError.message("#myWarning macro requires a string literal")
3131
}

Examples/Sources/MacroExamples/Implementation/MemberAttribute/WrapStoredPropertiesMacro.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ public struct WrapStoredPropertiesMacro: MemberAttributeMacro {
3636
return []
3737
}
3838

39-
guard case let .argumentList(arguments) = node.arguments,
39+
guard case .argumentList(let arguments) = node.arguments,
4040
let firstElement = arguments.first,
4141
let stringLiteral = firstElement.expression
4242
.as(StringLiteralExprSyntax.self),
4343
stringLiteral.segments.count == 1,
44-
case let .stringSegment(wrapperName)? = stringLiteral.segments.first
44+
case .stringSegment(let wrapperName)? = stringLiteral.segments.first
4545
else {
4646
throw CustomError.message("macro requires a string literal containing the name of an attribute")
4747
}

Examples/Sources/MacroExamples/Implementation/Peer/AddAsyncMacro.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public struct AddAsyncMacro: PeerMacro {
8989

9090
// Drop the @addAsync attribute from the new declaration.
9191
let newAttributeList = funcDecl.attributes.filter {
92-
guard case let .attribute(attribute) = $0,
92+
guard case .attribute(let attribute) = $0,
9393
let attributeType = attribute.attributeName.as(IdentifierTypeSyntax.self),
9494
let nodeType = node.attributeName.as(IdentifierTypeSyntax.self)
9595
else {

Examples/Sources/MacroExamples/Implementation/Peer/AddCompletionHandlerMacro.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public struct AddCompletionHandlerMacro: PeerMacro {
128128

129129
// Drop the @addCompletionHandler attribute from the new declaration.
130130
let newAttributeList = funcDecl.attributes.filter {
131-
guard case let .attribute(attribute) = $0,
131+
guard case .attribute(let attribute) = $0,
132132
let attributeType = attribute.attributeName.as(IdentifierTypeSyntax.self),
133133
let nodeType = node.attributeName.as(IdentifierTypeSyntax.self)
134134
else {

Sources/SwiftCompilerPluginMessageHandling/JSON/CodingUtilities.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ internal enum _CodingPathNode {
2626
switch self {
2727
case .root:
2828
return []
29-
case let .node(key, parent):
29+
case .node(let key, let parent):
3030
return parent.path + [key]
31-
case let .indexNode(index, parent):
31+
case .indexNode(let index, let parent):
3232
return parent.path + [_CodingKey(index: index)]
3333
}
3434
}
@@ -87,17 +87,17 @@ internal enum _CodingKey: CodingKey {
8787

8888
var stringValue: String {
8989
switch self {
90-
case let .string(str): return str
91-
case let .int(int): return "\(int)"
92-
case let .index(index): return "Index \(index)"
90+
case .string(let str): return str
91+
case .int(let int): return "\(int)"
92+
case .index(let index): return "Index \(index)"
9393
}
9494
}
9595

9696
var intValue: Int? {
9797
switch self {
9898
case .string: return nil
99-
case let .int(int): return int
100-
case let .index(index): return index
99+
case .int(let int): return int
100+
case .index(let index): return index
101101
}
102102
}
103103
}

Sources/SwiftCompilerPluginMessageHandling/LRUCache.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ public class LRUCache<Key: Hashable, Value> {
5656

5757
set {
5858
switch (table[key], newValue) {
59-
case let (nil, newValue?): // create.
59+
case (nil, let newValue?): // create.
6060
self.ensureCapacityForNewValue()
6161
let node = _Node(key: key, value: newValue)
6262
addToHead(node: node)
6363
table[key] = node
6464

65-
case let (node?, newValue?): // update.
65+
case (let node?, let newValue?): // update.
6666
moveToHead(node: node)
6767
node.value = newValue
6868

69-
case let (node?, nil): // delete.
69+
case (let node?, nil): // delete.
7070
remove(node: node)
7171
table[key] = nil
7272

Sources/SwiftParser/Statements.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ extension Parser {
293293
}
294294

295295
switch kind {
296-
case let .optional(unexpectedBeforeBindingKeyword, bindingSpecifier, pattern):
296+
case .optional(let unexpectedBeforeBindingKeyword, let bindingSpecifier, let pattern):
297297
return .optionalBinding(
298298
RawOptionalBindingConditionSyntax(
299299
unexpectedBeforeBindingKeyword,
@@ -304,7 +304,7 @@ extension Parser {
304304
arena: self.arena
305305
)
306306
)
307-
case let .pattern(caseKeyword, pattern):
307+
case .pattern(let caseKeyword, let pattern):
308308
return .matchingPattern(
309309
RawMatchingPatternConditionSyntax(
310310
caseKeyword: caseKeyword,

Sources/SwiftRefactor/ConvertComputedPropertyToStored.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import SwiftSyntax
1919
public struct ConvertComputedPropertyToStored: SyntaxRefactoringProvider {
2020
public static func refactor(syntax: VariableDeclSyntax, in context: ()) -> VariableDeclSyntax? {
2121
guard syntax.bindings.count == 1, let binding = syntax.bindings.first,
22-
let accessorBlock = binding.accessorBlock, case let .getter(body) = accessorBlock.accessors, !body.isEmpty
22+
let accessorBlock = binding.accessorBlock, case .getter(let body) = accessorBlock.accessors, !body.isEmpty
2323
else {
2424
return nil
2525
}

Sources/SwiftRefactor/ExpandEditorPlaceholder.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ struct ExpandSingleEditorPlaceholder: EditRefactoringProvider {
9494

9595
let expanded: String
9696
switch placeholder {
97-
case let .basic(text):
97+
case .basic(let text):
9898
expanded = String(text)
99-
case let .typed(text, type):
99+
case .typed(let text, let type):
100100
if let functionType = type.as(FunctionTypeSyntax.self) {
101101
let basicFormat = BasicFormat(
102102
indentationWidth: context.indentationWidth,
@@ -326,7 +326,7 @@ extension FunctionCallExprSyntax {
326326
guard let expr = arg.expression.as(DeclReferenceExprSyntax.self),
327327
expr.baseName.isEditorPlaceholder,
328328
let data = EditorPlaceholderData(token: expr.baseName),
329-
case let .typed(_, type) = data,
329+
case .typed(_, let type) = data,
330330
type.is(FunctionTypeSyntax.self)
331331
else {
332332
break

Sources/SwiftSyntax/Documentation.docc/Resources/Formatter.step10.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ import SwiftSyntax
3838
items[..<pivotPoint]
3939
.sort { lhs, rhs in
4040
guard
41-
case let .import(lhsImport, _) = lhs,
42-
case let .import(rhsImport, _) = rhs
41+
case .import(let lhsImport, _) = lhs,
42+
case .import(let rhsImport, _) = rhs
4343
else {
4444
fatalError("Partition must only contain import items!")
4545
}

Sources/SwiftSyntax/Documentation.docc/Resources/Formatter.step11.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ import SwiftSyntax
3838
items[..<pivotPoint]
3939
.sort { lhs, rhs in
4040
guard
41-
case let .import(lhsImport, _) = lhs,
42-
case let .import(rhsImport, _) = rhs
41+
case .import(let lhsImport, _) = lhs,
42+
case .import(let rhsImport, _) = rhs
4343
else {
4444
fatalError("Partition must only contain import items!")
4545
}

Sources/SwiftSyntax/Documentation.docc/Resources/Formatter.step8.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ import SwiftSyntax
3838
items[..<pivotPoint]
3939
.sort { lhs, rhs in
4040
guard
41-
case let .import(lhsImport, _) = lhs,
42-
case let .import(rhsImport, _) = rhs
41+
case .import(let lhsImport, _) = lhs,
42+
case .import(let rhsImport, _) = rhs
4343
else {
4444
fatalError("Partition must only contain import items!")
4545
}

Sources/SwiftSyntax/Documentation.docc/Resources/Formatter.step9.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ import SwiftSyntax
3838
items[..<pivotPoint]
3939
.sort { lhs, rhs in
4040
guard
41-
case let .import(lhsImport, _) = lhs,
42-
case let .import(rhsImport, _) = rhs
41+
case .import(let lhsImport, _) = lhs,
42+
case .import(let rhsImport, _) = rhs
4343
else {
4444
fatalError("Partition must only contain import items!")
4545
}

Sources/SwiftSyntax/SourceLocation.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -571,36 +571,36 @@ fileprivate extension RawTriviaPiece {
571571
) -> SourceLength {
572572
var lineLength = prefix
573573
switch self {
574-
case let .spaces(count),
575-
let .tabs(count),
576-
let .verticalTabs(count),
577-
let .formfeeds(count),
578-
let .backslashes(count),
579-
let .pounds(count):
574+
case .spaces(let count),
575+
.tabs(let count),
576+
.verticalTabs(let count),
577+
.formfeeds(let count),
578+
.backslashes(let count),
579+
.pounds(let count):
580580
lineLength += SourceLength(utf8Length: count)
581-
case let .newlines(count),
582-
let .carriageReturns(count):
581+
case .newlines(let count),
582+
.carriageReturns(let count):
583583
let newLineLength = SourceLength(utf8Length: 1)
584584
body(lineLength + newLineLength)
585585
for _ in 1..<count {
586586
body(newLineLength)
587587
}
588588
lineLength = .zero
589-
case let .carriageReturnLineFeeds(count):
589+
case .carriageReturnLineFeeds(let count):
590590
let carriageReturnLineLength = SourceLength(utf8Length: 2)
591591
body(lineLength + carriageReturnLineLength)
592592
for _ in 1..<count {
593593
body(carriageReturnLineLength)
594594
}
595595
lineLength = .zero
596-
case let .lineComment(text),
597-
let .docLineComment(text):
596+
case .lineComment(let text),
597+
.docLineComment(let text):
598598
// Line comments are not supposed to contain newlines.
599599
precondition(!text.containsSwiftNewline(), "line comment created that contained a new-line character")
600600
lineLength += SourceLength(utf8Length: text.count)
601-
case let .blockComment(text),
602-
let .docBlockComment(text),
603-
let .unexpectedText(text):
601+
case .blockComment(let text),
602+
.docBlockComment(let text),
603+
.unexpectedText(let text):
604604
lineLength = text.forEachLineLength(prefix: lineLength, body: body)
605605
}
606606
return lineLength

Sources/SwiftSyntaxMacroExpansion/MacroReplacement.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ extension MacroDeclSyntax {
372372
) -> ExprSyntax {
373373
// Dig out the argument list.
374374
let argumentList: LabeledExprListSyntax?
375-
if case let .argumentList(argList) = node.arguments {
375+
if case .argumentList(let argList) = node.arguments {
376376
argumentList = argList
377377
} else {
378378
argumentList = nil

Sources/SwiftSyntaxMacroExpansion/MacroSystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ extension MacroApplication {
993993
}
994994

995995
return attributedNode.attributes.compactMap {
996-
guard case let .attribute(attribute) = $0,
996+
guard case .attribute(let attribute) = $0,
997997
let attributeName = attribute.attributeName.as(IdentifierTypeSyntax.self)?.name.text,
998998
let macroSpec = macroSystem.lookup(attributeName)
999999
else {

Sources/_SwiftSyntaxTestSupport/Syntax+Assertions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ public enum SubtreeError: Error, CustomStringConvertible {
161161

162162
public var description: String {
163163
switch self {
164-
case let .invalidMarker(name):
164+
case .invalidMarker(let name):
165165
return "Could not find marker with name '\(name)'"
166-
case let .invalidSubtree(tree, afterUTF8Offset, type):
166+
case .invalidSubtree(let tree, let afterUTF8Offset, let type):
167167
return
168168
"Could not find subtree after UTF8 offset \(afterUTF8Offset) with type \(type) in:\n\(tree.debugDescription)"
169169
}

Tests/SwiftOperatorsTest/OperatorTableTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class OperatorPrecedenceTests: XCTestCase {
214214
}
215215

216216
XCTAssertEqual(errors.count, 2)
217-
guard case let .operatorAlreadyExists(existing, new) = errors[0] else {
217+
guard case .operatorAlreadyExists(let existing, let new) = errors[0] else {
218218
XCTFail("expected an 'operator already exists' error")
219219
return
220220
}
@@ -223,7 +223,7 @@ class OperatorPrecedenceTests: XCTestCase {
223223
_ = existing
224224
_ = new
225225

226-
guard case let .groupAlreadyExists(existingGroup, newGroup) = errors[1] else {
226+
guard case .groupAlreadyExists(let existingGroup, let newGroup) = errors[1] else {
227227
XCTFail("expected a 'group already exists' error")
228228
return
229229
}
@@ -254,7 +254,7 @@ class OperatorPrecedenceTests: XCTestCase {
254254
}
255255

256256
XCTAssertEqual(errors.count, 2)
257-
guard case let .operatorAlreadyExists(existing, new) = errors[0] else {
257+
guard case .operatorAlreadyExists(let existing, let new) = errors[0] else {
258258
XCTFail("expected an 'operator already exists' error")
259259
return
260260
}
@@ -305,7 +305,7 @@ class OperatorPrecedenceTests: XCTestCase {
305305
}
306306

307307
XCTAssertEqual(errors.count, 2)
308-
guard case let .missingGroup(groupName, location) = errors[0] else {
308+
guard case .missingGroup(let groupName, let location) = errors[0] else {
309309
XCTFail("expected a 'missing group' error")
310310
return
311311
}
@@ -324,7 +324,7 @@ class OperatorPrecedenceTests: XCTestCase {
324324
}
325325

326326
XCTAssertEqual(errors.count, 1)
327-
guard case let .missingOperator(operatorName, location) = errors[0] else {
327+
guard case .missingOperator(let operatorName, let location) = errors[0] else {
328328
XCTFail("expected a 'missing operator' error")
329329
return
330330
}
@@ -344,7 +344,7 @@ class OperatorPrecedenceTests: XCTestCase {
344344

345345
XCTAssertEqual(errors.count, 1)
346346
guard
347-
case let .incomparableOperators(_, leftGroup, _, rightGroup) =
347+
case .incomparableOperators(_, let leftGroup, _, let rightGroup) =
348348
errors[0]
349349
else {
350350
XCTFail("expected an 'incomparable operator' error")
@@ -369,7 +369,7 @@ class OperatorPrecedenceTests: XCTestCase {
369369

370370
XCTAssertEqual(errors.count, 1)
371371
guard
372-
case let .incomparableOperators(_, leftGroup, _, rightGroup) =
372+
case .incomparableOperators(_, let leftGroup, _, let rightGroup) =
373373
errors[0]
374374
else {
375375
XCTFail("expected an 'incomparable operator' error")

Tests/SwiftSyntaxMacroExpansionTest/DeclarationMacroTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ final class DeclarationMacroTests: XCTestCase {
5555
let stringLiteral = firstElement.expression
5656
.as(StringLiteralExprSyntax.self),
5757
stringLiteral.segments.count == 1,
58-
case let .stringSegment(messageString) = stringLiteral.segments.first
58+
case .stringSegment(let messageString) = stringLiteral.segments.first
5959
else {
6060
throw SwiftSyntaxMacros.MacroExpansionErrorMessage("#error macro requires a string literal")
6161
}
@@ -118,7 +118,7 @@ final class DeclarationMacroTests: XCTestCase {
118118
) throws -> [DeclSyntax] {
119119
guard let stringLiteral = node.arguments.first?.expression.as(StringLiteralExprSyntax.self),
120120
stringLiteral.segments.count == 1,
121-
case let .stringSegment(prefix) = stringLiteral.segments.first
121+
case .stringSegment(let prefix) = stringLiteral.segments.first
122122
else {
123123
throw SwiftSyntaxMacros.MacroExpansionErrorMessage(
124124
"#bitwidthNumberedStructs macro requires a string literal"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy