Skip to content

Commit a4e9fe3

Browse files
committed
Delete dependsOn support
1 parent f4acb89 commit a4e9fe3

28 files changed

+19
-1418
lines changed

CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift

-6
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ public enum Keyword: CaseIterable {
167167
case `default`
168168
case `defer`
169169
case `deinit`
170-
case dependsOn
171170
case deprecated
172171
case derivative
173172
case didSet
@@ -257,7 +256,6 @@ public enum Keyword: CaseIterable {
257256
case reverse
258257
case right
259258
case safe
260-
case scoped
261259
case `self`
262260
case sending
263261
case `Self`
@@ -476,8 +474,6 @@ public enum Keyword: CaseIterable {
476474
return KeywordSpec("defer", isLexerClassified: true)
477475
case .deinit:
478476
return KeywordSpec("deinit", isLexerClassified: true)
479-
case .dependsOn:
480-
return KeywordSpec("dependsOn", experimentalFeature: .nonescapableTypes)
481477
case .deprecated:
482478
return KeywordSpec("deprecated")
483479
case .derivative:
@@ -654,8 +650,6 @@ public enum Keyword: CaseIterable {
654650
return KeywordSpec("right")
655651
case .safe:
656652
return KeywordSpec("safe")
657-
case .scoped:
658-
return KeywordSpec("scoped", experimentalFeature: .nonescapableTypes)
659653
case .self:
660654
return KeywordSpec("self", isLexerClassified: true)
661655
case .Self:

CodeGeneration/Sources/SyntaxSupport/SyntaxNodeKind.swift

-4
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,6 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible, TypeCon
182182
case labeledSpecializeArgument
183183
case labeledStmt
184184
case layoutRequirement
185-
case lifetimeSpecifierArgument
186-
case lifetimeSpecifierArgumentList
187-
case lifetimeTypeSpecifier
188185
case macroDecl
189186
case macroExpansionDecl
190187
case macroExpansionExpr
@@ -290,7 +287,6 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible, TypeCon
290287
case typeExpr
291288
case typeInitializerClause
292289
case typeSpecifier
293-
case lifetimeSpecifierArguments
294290
case typeSpecifierList
295291
case unavailableFromAsyncAttributeArguments
296292
case underscorePrivateAttributeArguments

CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift

+1-76
Original file line numberDiff line numberDiff line change
@@ -500,81 +500,6 @@ public let TYPE_NODES: [Node] = [
500500
]
501501
),
502502

503-
Node(
504-
kind: .lifetimeSpecifierArgument,
505-
base: .syntax,
506-
experimentalFeature: .nonescapableTypes,
507-
nameForDiagnostics: nil,
508-
documentation: """
509-
A single argument that can be added to a lifetime specifier like `borrow`, `mutate`, `consume` or `copy`.
510-
511-
### Example
512-
`data` in `func foo(data: Array<Item>) -> borrow(data) ComplexReferenceType`
513-
""",
514-
traits: [
515-
"WithTrailingComma"
516-
],
517-
children: [
518-
Child(
519-
name: "parameter",
520-
kind: .token(choices: [.token(.identifier), .keyword(.self), .token(.integerLiteral)]),
521-
nameForDiagnostics: "parameter reference",
522-
documentation: """
523-
The parameter on which the lifetime of this type depends.
524-
525-
This can be an identifier referring to an external parameter name, an integer literal to refer to an unnamed
526-
parameter or `self` if the type's lifetime depends on the object the method is called on.
527-
"""
528-
),
529-
Child(
530-
name: "trailingComma",
531-
kind: .token(choices: [.token(.comma)]),
532-
isOptional: true
533-
),
534-
]
535-
),
536-
537-
Node(
538-
kind: .lifetimeSpecifierArgumentList,
539-
base: .syntaxCollection,
540-
experimentalFeature: .nonescapableTypes,
541-
nameForDiagnostics: nil,
542-
elementChoices: [.lifetimeSpecifierArgument]
543-
),
544-
545-
Node(
546-
kind: .lifetimeTypeSpecifier,
547-
base: .syntax,
548-
experimentalFeature: .nonescapableTypes,
549-
nameForDiagnostics: "lifetime specifier",
550-
documentation: "A specifier that specifies function parameter on whose lifetime a type depends",
551-
children: [
552-
Child(
553-
name: "dependsOnKeyword",
554-
kind: .token(choices: [.keyword(.dependsOn)]),
555-
documentation: "lifetime dependence specifier on the return type"
556-
),
557-
Child(
558-
name: "leftParen",
559-
kind: .token(choices: [.token(.leftParen)])
560-
),
561-
Child(
562-
name: "scopedKeyword",
563-
kind: .token(choices: [.keyword(.scoped)]),
564-
documentation: "lifetime of return value is scoped to the lifetime of the original value",
565-
isOptional: true
566-
),
567-
Child(
568-
name: "arguments",
569-
kind: .collection(kind: .lifetimeSpecifierArgumentList, collectionElementName: "Arguments")
570-
),
571-
Child(
572-
name: "rightParen",
573-
kind: .token(choices: [.token(.rightParen)])
574-
),
575-
]
576-
),
577-
578503
Node(
579504
kind: .simpleTypeSpecifier,
580505
base: .syntax,
@@ -602,6 +527,6 @@ public let TYPE_NODES: [Node] = [
602527
kind: .typeSpecifierList,
603528
base: .syntaxCollection,
604529
nameForDiagnostics: nil,
605-
elementChoices: [.simpleTypeSpecifier, .lifetimeTypeSpecifier]
530+
elementChoices: [.simpleTypeSpecifier]
606531
),
607532
]

Sources/SwiftParser/TokenPrecedence.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ enum TokenPrecedence: Comparable {
236236
.convenience, .override, .package, .open,
237237
.__setter_access, .indirect, .isolated, .nonisolated, .distributed, ._local,
238238
.inout, ._mutating, ._borrow, ._borrowing, .borrowing, ._consuming, .consuming, .consume,
239-
.dependsOn, .scoped, .sending,
239+
.sending,
240240
// Accessors
241241
.get, .set, .didSet, .willSet, .unsafeAddress, .addressWithOwner, .addressWithNativeOwner, .unsafeMutableAddress,
242242
.mutableAddressWithOwner, .mutableAddressWithNativeOwner, ._read, .read, ._modify, .modify,

Sources/SwiftParser/Types.swift

+6-72
Original file line numberDiff line numberDiff line change
@@ -874,69 +874,11 @@ extension Parser.Lookahead {
874874
}
875875

876876
extension Parser {
877-
private mutating func parseLifetimeTypeSpecifier() -> RawTypeSpecifierListSyntax.Element {
878-
let (unexpectedBeforeDependsOnKeyword, dependsOnKeyword) = self.expect(.keyword(.dependsOn))
879-
880-
guard let leftParen = self.consume(if: .leftParen) else {
881-
// If there is no left paren, add an entirely missing detail. Otherwise, we start to consume the following type
882-
// name as a token inside the detail, which leads to confusing recovery results.
883-
let lifetimeSpecifierArgumentList = RawLifetimeSpecifierArgumentListSyntax(
884-
elements: [
885-
RawLifetimeSpecifierArgumentSyntax(parameter: missingToken(.identifier), trailingComma: nil, arena: arena)
886-
],
887-
arena: self.arena
888-
)
889-
let lifetimeSpecifier = RawLifetimeTypeSpecifierSyntax(
890-
unexpectedBeforeDependsOnKeyword,
891-
dependsOnKeyword: dependsOnKeyword,
892-
leftParen: missingToken(.leftParen),
893-
scopedKeyword: nil,
894-
arguments: lifetimeSpecifierArgumentList,
895-
rightParen: missingToken(.rightParen),
896-
arena: self.arena
897-
)
898-
return .lifetimeTypeSpecifier(lifetimeSpecifier)
899-
}
900-
901-
let scoped = self.consume(if: .keyword(.scoped))
902-
var keepGoing: RawTokenSyntax?
903-
var arguments: [RawLifetimeSpecifierArgumentSyntax] = []
904-
var loopProgress = LoopProgressCondition()
905-
repeat {
906-
let (unexpectedBeforeParameter, parameter) = self.expect(
907-
anyIn: LifetimeSpecifierArgumentSyntax.ParameterOptions.self,
908-
default: .identifier
909-
)
910-
keepGoing = self.consume(if: .comma)
911-
arguments.append(
912-
RawLifetimeSpecifierArgumentSyntax(
913-
unexpectedBeforeParameter,
914-
parameter: parameter,
915-
trailingComma: keepGoing,
916-
arena: arena
917-
)
918-
)
919-
} while keepGoing != nil && self.hasProgressed(&loopProgress)
920-
let lifetimeSpecifierArgumentList = RawLifetimeSpecifierArgumentListSyntax(elements: arguments, arena: self.arena)
921-
let (unexpectedBeforeRightParen, rightParen) = self.expect(.rightParen)
922-
let lifetimeSpecifier = RawLifetimeTypeSpecifierSyntax(
923-
unexpectedBeforeDependsOnKeyword,
924-
dependsOnKeyword: dependsOnKeyword,
925-
leftParen: leftParen,
926-
scopedKeyword: scoped,
927-
arguments: lifetimeSpecifierArgumentList,
928-
unexpectedBeforeRightParen,
929-
rightParen: rightParen,
930-
arena: self.arena
931-
)
932-
return .lifetimeTypeSpecifier(lifetimeSpecifier)
933-
}
934-
935877
private mutating func parseSimpleTypeSpecifier(
936878
specifierHandle: TokenConsumptionHandle
937-
) -> RawTypeSpecifierListSyntax.Element {
879+
) -> RawSimpleTypeSpecifierSyntax {
938880
let specifier = self.eat(specifierHandle)
939-
return .simpleTypeSpecifier(RawSimpleTypeSpecifierSyntax(specifier: specifier, arena: arena))
881+
return RawSimpleTypeSpecifierSyntax(specifier: specifier, arena: arena)
940882
}
941883

942884
mutating func parseTypeAttributeList(
@@ -945,26 +887,18 @@ extension Parser {
945887
specifiers: RawTypeSpecifierListSyntax,
946888
attributes: RawAttributeListSyntax
947889
)? {
948-
var specifiers: [RawTypeSpecifierListSyntax.Element] = []
890+
var specifiers: [RawSimpleTypeSpecifierSyntax] = []
949891
SPECIFIER_PARSING: while canHaveParameterSpecifier {
950892
if let (_, specifierHandle) = self.at(anyIn: SimpleTypeSpecifierSyntax.SpecifierOptions.self) {
951893
specifiers.append(parseSimpleTypeSpecifier(specifierHandle: specifierHandle))
952-
} else if self.at(.keyword(.dependsOn)) {
953-
if self.experimentalFeatures.contains(.nonescapableTypes) {
954-
specifiers.append(parseLifetimeTypeSpecifier())
955-
} else {
956-
break SPECIFIER_PARSING
957-
}
958894
} else {
959895
break SPECIFIER_PARSING
960896
}
961897
}
962898
specifiers += misplacedSpecifiers.map {
963-
.simpleTypeSpecifier(
964-
RawSimpleTypeSpecifierSyntax(
965-
specifier: missingToken($0.tokenKind, text: $0.tokenText),
966-
arena: arena
967-
)
899+
RawSimpleTypeSpecifierSyntax(
900+
specifier: missingToken($0.tokenKind, text: $0.tokenText),
901+
arena: arena
968902
)
969903
}
970904

Sources/SwiftParser/generated/Parser+TokenSpecSet.swift

-61
Original file line numberDiff line numberDiff line change
@@ -2679,67 +2679,6 @@ extension LayoutRequirementSyntax {
26792679
}
26802680
}
26812681

2682-
extension LifetimeSpecifierArgumentSyntax {
2683-
@_spi(Diagnostics)
2684-
public enum ParameterOptions: TokenSpecSet {
2685-
case identifier
2686-
case `self`
2687-
case integerLiteral
2688-
2689-
init?(lexeme: Lexer.Lexeme, experimentalFeatures: Parser.ExperimentalFeatures) {
2690-
switch PrepareForKeywordMatch(lexeme) {
2691-
case TokenSpec(.identifier):
2692-
self = .identifier
2693-
case TokenSpec(.self):
2694-
self = .self
2695-
case TokenSpec(.integerLiteral):
2696-
self = .integerLiteral
2697-
default:
2698-
return nil
2699-
}
2700-
}
2701-
2702-
public init?(token: TokenSyntax) {
2703-
switch token {
2704-
case TokenSpec(.identifier):
2705-
self = .identifier
2706-
case TokenSpec(.self):
2707-
self = .self
2708-
case TokenSpec(.integerLiteral):
2709-
self = .integerLiteral
2710-
default:
2711-
return nil
2712-
}
2713-
}
2714-
2715-
var spec: TokenSpec {
2716-
switch self {
2717-
case .identifier:
2718-
return .identifier
2719-
case .self:
2720-
return .keyword(.self)
2721-
case .integerLiteral:
2722-
return .integerLiteral
2723-
}
2724-
}
2725-
2726-
/// Returns a token that satisfies the `TokenSpec` of this case.
2727-
///
2728-
/// If the token kind of this spec has variable text, e.g. for an identifier, this returns a token with empty text.
2729-
@_spi(Diagnostics)
2730-
public var tokenSyntax: TokenSyntax {
2731-
switch self {
2732-
case .identifier:
2733-
return .identifier("")
2734-
case .self:
2735-
return .keyword(.self)
2736-
case .integerLiteral:
2737-
return .integerLiteral("")
2738-
}
2739-
}
2740-
}
2741-
}
2742-
27432682
extension MemberTypeSyntax {
27442683
@_spi(Diagnostics)
27452684
public enum NameOptions: TokenSpecSet {

Sources/SwiftParserDiagnostics/SyntaxExtensions.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ extension TypeSpecifierListSyntax {
210210
var simpleSpecifiers: [TokenSyntax] {
211211
return self.compactMap { specifier in
212212
switch specifier {
213-
case .simpleTypeSpecifier(let specifier): return specifier.specifier
214-
case .lifetimeTypeSpecifier: return nil
213+
case let specifier: return specifier.specifier
215214
#if RESILIENT_LIBRARIES
216215
@unknown default:
217216
fatalError()

Sources/SwiftParserDiagnostics/generated/ChildNameForDiagnostics.swift

-2
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,6 @@ private func childNameForDiagnostics(_ keyPath: AnyKeyPath) -> String? {
224224
return "size"
225225
case \LayoutRequirementSyntax.alignment:
226226
return "alignment"
227-
case \LifetimeSpecifierArgumentSyntax.parameter:
228-
return "parameter reference"
229227
case \MacroDeclSyntax.attributes:
230228
return "attributes"
231229
case \MacroDeclSyntax.modifiers:

Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift

-2
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ extension SyntaxKind {
251251
return "labeled statement"
252252
case .layoutRequirement:
253253
return "layout requirement"
254-
case .lifetimeTypeSpecifier:
255-
return "lifetime specifier"
256254
case .macroDecl:
257255
return "macro"
258256
case .macroExpansionDecl:

Sources/SwiftSyntax/SwiftSyntaxCompatibility.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extension AttributedTypeSyntax {
5252
) {
5353
let specifiers: TypeSpecifierListSyntax
5454
if let specifier {
55-
specifiers = [.simpleTypeSpecifier(SimpleTypeSpecifierSyntax(specifier: specifier))]
55+
specifiers = [SimpleTypeSpecifierSyntax(specifier: specifier)]
5656
} else {
5757
specifiers = []
5858
}
@@ -82,14 +82,14 @@ extension AttributedTypeSyntax {
8282
@available(*, deprecated, message: "Access the specifiers list instead")
8383
public var specifier: TokenSyntax? {
8484
get {
85-
if case .simpleTypeSpecifier(let simpleSpecifier) = specifiers.first {
85+
if let simpleSpecifier = specifiers.first {
8686
return simpleSpecifier.specifier
8787
}
8888
return nil
8989
}
9090
set {
9191
if let newValue {
92-
specifiers = [.simpleTypeSpecifier(SimpleTypeSpecifierSyntax(specifier: newValue))]
92+
specifiers = [SimpleTypeSpecifierSyntax(specifier: newValue)]
9393
} else {
9494
specifiers = []
9595
}

0 commit comments

Comments
 (0)