Skip to content

Commit 55a4b03

Browse files
committed
Enable unacceptable language check
Fixes #2990
1 parent b4a0be3 commit 55a4b03

File tree

5 files changed

+38
-52
lines changed

5 files changed

+38
-52
lines changed

.github/workflows/pull_request.yml

-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,5 @@ jobs:
2020
docs_check_enabled: false
2121
# https://github.com/swiftlang/swift-syntax/issues/2988
2222
format_check_enabled: false
23-
# https://github.com/swiftlang/swift-syntax/issues/2990
24-
unacceptable_language_check_enabled: false
2523
# https://github.com/swiftlang/swift-syntax/issues/2991
2624
yamllint_check_enabled: false

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift

+6-8
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
4242
/// These methods enable casting between syntax node types within the same
4343
/// base node protocol hierarchy (e.g., ``DeclSyntaxProtocol``).
4444
///
45-
/// While ``SyntaxProtocol`` offers general casting methods (``SyntaxProtocol.as(_:)``,
45+
/// While ``SyntaxProtocol`` offers general casting methods (``SyntaxProtocol.as(_:)``,
4646
/// ``SyntaxProtocol.is(_:)``, and ``SyntaxProtocol.cast(_:)``), these often aren't
4747
/// appropriate for use on types conforming to a specific base node protocol
4848
/// like ``\#(node.kind.protocolType)``. That's because at this level,
@@ -51,7 +51,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
5151
///
5252
/// To guide developers toward correct usage, this extension provides overloads
5353
/// of these casting methods that are restricted to the same base node type.
54-
/// Furthermore, it marks the inherited casting methods from ``SyntaxProtocol`` as
54+
/// Furthermore, it marks the inherited casting methods from ``SyntaxProtocol`` as
5555
/// deprecated, indicating that they will always fail when used in this context.
5656
extension \#(node.kind.protocolType) {
5757
/// Checks if the current syntax node can be cast to a given specialized syntax type.
@@ -184,9 +184,8 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
184184
"""
185185
/// Create a \(raw: node.kind.doccLink) node from a specialized syntax node.
186186
public init(_ syntax: __shared some \(node.kind.protocolType)) {
187-
// We know this cast is going to succeed. Go through init(_: SyntaxData)
188-
// to do a sanity check and verify the kind matches in debug builds and get
189-
// maximum performance in release builds.
187+
// We know this cast is going to succeed. Go through `init(_: SyntaxData)` just to double-check and
188+
// verify the kind matches in debug builds and get maximum performance in release builds.
190189
self = Syntax(syntax).cast(Self.self)
191190
}
192191
"""
@@ -205,9 +204,8 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
205204
DeclSyntax(
206205
"""
207206
public init(fromProtocol syntax: __shared \(node.kind.protocolType)) {
208-
// We know this cast is going to succeed. Go through init(_: SyntaxData)
209-
// to do a sanity check and verify the kind matches in debug builds and get
210-
// maximum performance in release builds.
207+
// We know this cast is going to succeed. Go through `init(_: SyntaxData)` just to double-check and
208+
// verify the kind matches in debug builds and get maximum performance in release builds.
211209
self = Syntax(syntax).cast(Self.self)
212210
}
213211
"""

Sources/SwiftParser/Expressions.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ extension Parser {
583583
) -> RawExprSyntax {
584584
// Try parse a single value statement as an expression (e.g do/if/switch).
585585
// Note we do this here in parseUnaryExpression as we don't allow postfix
586-
// syntax to hang off such expressions to avoid ambiguities such as postfix
586+
// syntax to be attached to such expressions to avoid ambiguities such as postfix
587587
// '.member', which can currently be parsed as a static dot member for a
588588
// result builder.
589589
switch self.at(anyIn: SingleValueStatementExpression.self) {

Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift

+30-40
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public protocol DeclSyntaxProtocol: SyntaxProtocol {}
2626
/// These methods enable casting between syntax node types within the same
2727
/// base node protocol hierarchy (e.g., ``DeclSyntaxProtocol``).
2828
///
29-
/// While ``SyntaxProtocol`` offers general casting methods (``SyntaxProtocol.as(_:)``,
29+
/// While ``SyntaxProtocol`` offers general casting methods (``SyntaxProtocol.as(_:)``,
3030
/// ``SyntaxProtocol.is(_:)``, and ``SyntaxProtocol.cast(_:)``), these often aren't
3131
/// appropriate for use on types conforming to a specific base node protocol
3232
/// like ``DeclSyntaxProtocol``. That's because at this level,
@@ -35,7 +35,7 @@ public protocol DeclSyntaxProtocol: SyntaxProtocol {}
3535
///
3636
/// To guide developers toward correct usage, this extension provides overloads
3737
/// of these casting methods that are restricted to the same base node type.
38-
/// Furthermore, it marks the inherited casting methods from ``SyntaxProtocol`` as
38+
/// Furthermore, it marks the inherited casting methods from ``SyntaxProtocol`` as
3939
/// deprecated, indicating that they will always fail when used in this context.
4040
extension DeclSyntaxProtocol {
4141
/// Checks if the current syntax node can be cast to a given specialized syntax type.
@@ -184,9 +184,8 @@ public struct DeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
184184

185185
/// Create a ``DeclSyntax`` node from a specialized syntax node.
186186
public init(_ syntax: __shared some DeclSyntaxProtocol) {
187-
// We know this cast is going to succeed. Go through init(_: SyntaxData)
188-
// to do a sanity check and verify the kind matches in debug builds and get
189-
// maximum performance in release builds.
187+
// We know this cast is going to succeed. Go through `init(_: SyntaxData)` just to double-check and
188+
// verify the kind matches in debug builds and get maximum performance in release builds.
190189
self = Syntax(syntax).cast(Self.self)
191190
}
192191

@@ -199,9 +198,8 @@ public struct DeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
199198
}
200199

201200
public init(fromProtocol syntax: __shared DeclSyntaxProtocol) {
202-
// We know this cast is going to succeed. Go through init(_: SyntaxData)
203-
// to do a sanity check and verify the kind matches in debug builds and get
204-
// maximum performance in release builds.
201+
// We know this cast is going to succeed. Go through `init(_: SyntaxData)` just to double-check and
202+
// verify the kind matches in debug builds and get maximum performance in release builds.
205203
self = Syntax(syntax).cast(Self.self)
206204
}
207205

@@ -327,7 +325,7 @@ public protocol ExprSyntaxProtocol: SyntaxProtocol {}
327325
/// These methods enable casting between syntax node types within the same
328326
/// base node protocol hierarchy (e.g., ``DeclSyntaxProtocol``).
329327
///
330-
/// While ``SyntaxProtocol`` offers general casting methods (``SyntaxProtocol.as(_:)``,
328+
/// While ``SyntaxProtocol`` offers general casting methods (``SyntaxProtocol.as(_:)``,
331329
/// ``SyntaxProtocol.is(_:)``, and ``SyntaxProtocol.cast(_:)``), these often aren't
332330
/// appropriate for use on types conforming to a specific base node protocol
333331
/// like ``ExprSyntaxProtocol``. That's because at this level,
@@ -336,7 +334,7 @@ public protocol ExprSyntaxProtocol: SyntaxProtocol {}
336334
///
337335
/// To guide developers toward correct usage, this extension provides overloads
338336
/// of these casting methods that are restricted to the same base node type.
339-
/// Furthermore, it marks the inherited casting methods from ``SyntaxProtocol`` as
337+
/// Furthermore, it marks the inherited casting methods from ``SyntaxProtocol`` as
340338
/// deprecated, indicating that they will always fail when used in this context.
341339
extension ExprSyntaxProtocol {
342340
/// Checks if the current syntax node can be cast to a given specialized syntax type.
@@ -512,9 +510,8 @@ public struct ExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
512510

513511
/// Create a ``ExprSyntax`` node from a specialized syntax node.
514512
public init(_ syntax: __shared some ExprSyntaxProtocol) {
515-
// We know this cast is going to succeed. Go through init(_: SyntaxData)
516-
// to do a sanity check and verify the kind matches in debug builds and get
517-
// maximum performance in release builds.
513+
// We know this cast is going to succeed. Go through `init(_: SyntaxData)` just to double-check and
514+
// verify the kind matches in debug builds and get maximum performance in release builds.
518515
self = Syntax(syntax).cast(Self.self)
519516
}
520517

@@ -527,9 +524,8 @@ public struct ExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
527524
}
528525

529526
public init(fromProtocol syntax: __shared ExprSyntaxProtocol) {
530-
// We know this cast is going to succeed. Go through init(_: SyntaxData)
531-
// to do a sanity check and verify the kind matches in debug builds and get
532-
// maximum performance in release builds.
527+
// We know this cast is going to succeed. Go through `init(_: SyntaxData)` just to double-check and
528+
// verify the kind matches in debug builds and get maximum performance in release builds.
533529
self = Syntax(syntax).cast(Self.self)
534530
}
535531

@@ -685,7 +681,7 @@ public protocol PatternSyntaxProtocol: SyntaxProtocol {}
685681
/// These methods enable casting between syntax node types within the same
686682
/// base node protocol hierarchy (e.g., ``DeclSyntaxProtocol``).
687683
///
688-
/// While ``SyntaxProtocol`` offers general casting methods (``SyntaxProtocol.as(_:)``,
684+
/// While ``SyntaxProtocol`` offers general casting methods (``SyntaxProtocol.as(_:)``,
689685
/// ``SyntaxProtocol.is(_:)``, and ``SyntaxProtocol.cast(_:)``), these often aren't
690686
/// appropriate for use on types conforming to a specific base node protocol
691687
/// like ``PatternSyntaxProtocol``. That's because at this level,
@@ -694,7 +690,7 @@ public protocol PatternSyntaxProtocol: SyntaxProtocol {}
694690
///
695691
/// To guide developers toward correct usage, this extension provides overloads
696692
/// of these casting methods that are restricted to the same base node type.
697-
/// Furthermore, it marks the inherited casting methods from ``SyntaxProtocol`` as
693+
/// Furthermore, it marks the inherited casting methods from ``SyntaxProtocol`` as
698694
/// deprecated, indicating that they will always fail when used in this context.
699695
extension PatternSyntaxProtocol {
700696
/// Checks if the current syntax node can be cast to a given specialized syntax type.
@@ -826,9 +822,8 @@ public struct PatternSyntax: PatternSyntaxProtocol, SyntaxHashable {
826822

827823
/// Create a ``PatternSyntax`` node from a specialized syntax node.
828824
public init(_ syntax: __shared some PatternSyntaxProtocol) {
829-
// We know this cast is going to succeed. Go through init(_: SyntaxData)
830-
// to do a sanity check and verify the kind matches in debug builds and get
831-
// maximum performance in release builds.
825+
// We know this cast is going to succeed. Go through `init(_: SyntaxData)` just to double-check and
826+
// verify the kind matches in debug builds and get maximum performance in release builds.
832827
self = Syntax(syntax).cast(Self.self)
833828
}
834829

@@ -841,9 +836,8 @@ public struct PatternSyntax: PatternSyntaxProtocol, SyntaxHashable {
841836
}
842837

843838
public init(fromProtocol syntax: __shared PatternSyntaxProtocol) {
844-
// We know this cast is going to succeed. Go through init(_: SyntaxData)
845-
// to do a sanity check and verify the kind matches in debug builds and get
846-
// maximum performance in release builds.
839+
// We know this cast is going to succeed. Go through `init(_: SyntaxData)` just to double-check and
840+
// verify the kind matches in debug builds and get maximum performance in release builds.
847841
self = Syntax(syntax).cast(Self.self)
848842
}
849843

@@ -952,7 +946,7 @@ public protocol StmtSyntaxProtocol: SyntaxProtocol {}
952946
/// These methods enable casting between syntax node types within the same
953947
/// base node protocol hierarchy (e.g., ``DeclSyntaxProtocol``).
954948
///
955-
/// While ``SyntaxProtocol`` offers general casting methods (``SyntaxProtocol.as(_:)``,
949+
/// While ``SyntaxProtocol`` offers general casting methods (``SyntaxProtocol.as(_:)``,
956950
/// ``SyntaxProtocol.is(_:)``, and ``SyntaxProtocol.cast(_:)``), these often aren't
957951
/// appropriate for use on types conforming to a specific base node protocol
958952
/// like ``StmtSyntaxProtocol``. That's because at this level,
@@ -961,7 +955,7 @@ public protocol StmtSyntaxProtocol: SyntaxProtocol {}
961955
///
962956
/// To guide developers toward correct usage, this extension provides overloads
963957
/// of these casting methods that are restricted to the same base node type.
964-
/// Furthermore, it marks the inherited casting methods from ``SyntaxProtocol`` as
958+
/// Furthermore, it marks the inherited casting methods from ``SyntaxProtocol`` as
965959
/// deprecated, indicating that they will always fail when used in this context.
966960
extension StmtSyntaxProtocol {
967961
/// Checks if the current syntax node can be cast to a given specialized syntax type.
@@ -1102,9 +1096,8 @@ public struct StmtSyntax: StmtSyntaxProtocol, SyntaxHashable {
11021096

11031097
/// Create a ``StmtSyntax`` node from a specialized syntax node.
11041098
public init(_ syntax: __shared some StmtSyntaxProtocol) {
1105-
// We know this cast is going to succeed. Go through init(_: SyntaxData)
1106-
// to do a sanity check and verify the kind matches in debug builds and get
1107-
// maximum performance in release builds.
1099+
// We know this cast is going to succeed. Go through `init(_: SyntaxData)` just to double-check and
1100+
// verify the kind matches in debug builds and get maximum performance in release builds.
11081101
self = Syntax(syntax).cast(Self.self)
11091102
}
11101103

@@ -1117,9 +1110,8 @@ public struct StmtSyntax: StmtSyntaxProtocol, SyntaxHashable {
11171110
}
11181111

11191112
public init(fromProtocol syntax: __shared StmtSyntaxProtocol) {
1120-
// We know this cast is going to succeed. Go through init(_: SyntaxData)
1121-
// to do a sanity check and verify the kind matches in debug builds and get
1122-
// maximum performance in release builds.
1113+
// We know this cast is going to succeed. Go through `init(_: SyntaxData)` just to double-check and
1114+
// verify the kind matches in debug builds and get maximum performance in release builds.
11231115
self = Syntax(syntax).cast(Self.self)
11241116
}
11251117

@@ -1238,7 +1230,7 @@ public protocol TypeSyntaxProtocol: SyntaxProtocol {}
12381230
/// These methods enable casting between syntax node types within the same
12391231
/// base node protocol hierarchy (e.g., ``DeclSyntaxProtocol``).
12401232
///
1241-
/// While ``SyntaxProtocol`` offers general casting methods (``SyntaxProtocol.as(_:)``,
1233+
/// While ``SyntaxProtocol`` offers general casting methods (``SyntaxProtocol.as(_:)``,
12421234
/// ``SyntaxProtocol.is(_:)``, and ``SyntaxProtocol.cast(_:)``), these often aren't
12431235
/// appropriate for use on types conforming to a specific base node protocol
12441236
/// like ``TypeSyntaxProtocol``. That's because at this level,
@@ -1247,7 +1239,7 @@ public protocol TypeSyntaxProtocol: SyntaxProtocol {}
12471239
///
12481240
/// To guide developers toward correct usage, this extension provides overloads
12491241
/// of these casting methods that are restricted to the same base node type.
1250-
/// Furthermore, it marks the inherited casting methods from ``SyntaxProtocol`` as
1242+
/// Furthermore, it marks the inherited casting methods from ``SyntaxProtocol`` as
12511243
/// deprecated, indicating that they will always fail when used in this context.
12521244
extension TypeSyntaxProtocol {
12531245
/// Checks if the current syntax node can be cast to a given specialized syntax type.
@@ -1390,9 +1382,8 @@ public struct TypeSyntax: TypeSyntaxProtocol, SyntaxHashable {
13901382

13911383
/// Create a ``TypeSyntax`` node from a specialized syntax node.
13921384
public init(_ syntax: __shared some TypeSyntaxProtocol) {
1393-
// We know this cast is going to succeed. Go through init(_: SyntaxData)
1394-
// to do a sanity check and verify the kind matches in debug builds and get
1395-
// maximum performance in release builds.
1385+
// We know this cast is going to succeed. Go through `init(_: SyntaxData)` just to double-check and
1386+
// verify the kind matches in debug builds and get maximum performance in release builds.
13961387
self = Syntax(syntax).cast(Self.self)
13971388
}
13981389

@@ -1405,9 +1396,8 @@ public struct TypeSyntax: TypeSyntaxProtocol, SyntaxHashable {
14051396
}
14061397

14071398
public init(fromProtocol syntax: __shared TypeSyntaxProtocol) {
1408-
// We know this cast is going to succeed. Go through init(_: SyntaxData)
1409-
// to do a sanity check and verify the kind matches in debug builds and get
1410-
// maximum performance in release builds.
1399+
// We know this cast is going to succeed. Go through `init(_: SyntaxData)` just to double-check and
1400+
// verify the kind matches in debug builds and get maximum performance in release builds.
14111401
self = Syntax(syntax).cast(Self.self)
14121402
}
14131403

SwiftParserCLI/Sources/swift-parser-cli/Commands/Reduce.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct Reduce: ParsableCommand {
9797
#if os(Windows)
9898
_ = TerminateProcess(process.processHandle, 0)
9999
#else
100-
kill(pid_t(process.processIdentifier), SIGKILL)
100+
kill(pid_t(process.processIdentifier), SIGKILL) // ignore-unacceptable-language
101101
#endif
102102
return .timeout
103103
}

0 commit comments

Comments
 (0)