diff --git a/CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift b/CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift index 2658b4e0b3f..f89ddb531d9 100644 --- a/CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift +++ b/CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift @@ -542,42 +542,17 @@ public let TYPE_NODES: [Node] = [ elementChoices: [.lifetimeSpecifierArgument] ), - Node( - kind: .lifetimeSpecifierArguments, - base: .syntax, - experimentalFeature: .nonescapableTypes, - nameForDiagnostics: nil, - documentation: """ - An optional argument passed to a type parameter. - - ### Example - `borrow(data)` in `func foo(data: Array) -> borrow(data) ComplexReferenceType` - """, - children: [ - Child( - name: "arguments", - kind: .collection(kind: .lifetimeSpecifierArgumentList, collectionElementName: "Arguments"), - documentation: """ - The function parameters that the lifetime of the annotated type depends on. - """ - ) - ] - ), - Node( kind: .lifetimeTypeSpecifier, base: .syntax, experimentalFeature: .nonescapableTypes, nameForDiagnostics: "lifetime specifier", documentation: "A specifier that specifies function parameter on whose lifetime a type depends", - traits: [ - "Parenthesized" - ], children: [ Child( name: "dependsOnKeyword", kind: .token(choices: [.keyword(.dependsOn)]), - documentation: "The specifier token that's attached to the type." + documentation: "lifetime dependence specifier on the return type" ), Child( name: "leftParen", @@ -586,11 +561,12 @@ public let TYPE_NODES: [Node] = [ Child( name: "scopedKeyword", kind: .token(choices: [.keyword(.scoped)]), + documentation: "lifetime of return value is scoped to the lifetime of the original value", isOptional: true ), Child( name: "arguments", - kind: .node(kind: .lifetimeSpecifierArguments) + kind: .collection(kind: .lifetimeSpecifierArgumentList, collectionElementName: "Arguments") ), Child( name: "rightParen", diff --git a/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift b/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift index 49028b06247..0decc847b3a 100644 --- a/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift +++ b/CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift @@ -550,6 +550,7 @@ class ValidateSyntaxNodes: XCTestCase { node: .yieldedExpressionsClause, message: "could conform to trait 'Parenthesized' but does not" ), + ValidationFailure(node: .lifetimeTypeSpecifier, message: "could conform to trait 'Parenthesized' but does not"), ] ) } diff --git a/Sources/SwiftParser/Types.swift b/Sources/SwiftParser/Types.swift index 99958f0deae..0c1102dabf2 100644 --- a/Sources/SwiftParser/Types.swift +++ b/Sources/SwiftParser/Types.swift @@ -901,25 +901,23 @@ extension Parser.Lookahead { extension Parser { private mutating func parseLifetimeTypeSpecifier() -> RawTypeSpecifierListSyntax.Element { - let specifier = self.eat(TokenSpec(.dependsOn)) + let (unexpectedBeforeDependsOnKeyword, dependsOnKeyword) = self.expect(.keyword(.dependsOn)) guard let leftParen = self.consume(if: .leftParen) else { // If there is no left paren, add an entirely missing detail. Otherwise, we start to consume the following type // name as a token inside the detail, which leads to confusing recovery results. - let arguments = RawLifetimeSpecifierArgumentsSyntax( - arguments: RawLifetimeSpecifierArgumentListSyntax( - elements: [ - RawLifetimeSpecifierArgumentSyntax(parameter: missingToken(.identifier), trailingComma: nil, arena: arena) - ], - arena: self.arena - ), + let lifetimeSpecifierArgumentList = RawLifetimeSpecifierArgumentListSyntax( + elements: [ + RawLifetimeSpecifierArgumentSyntax(parameter: missingToken(.identifier), trailingComma: nil, arena: arena) + ], arena: self.arena ) let lifetimeSpecifier = RawLifetimeTypeSpecifierSyntax( - dependsOnKeyword: specifier, + unexpectedBeforeDependsOnKeyword, + dependsOnKeyword: dependsOnKeyword, leftParen: missingToken(.leftParen), scopedKeyword: nil, - arguments: arguments, + arguments: lifetimeSpecifierArgumentList, rightParen: missingToken(.rightParen), arena: self.arena ) @@ -947,15 +945,12 @@ extension Parser { } while keepGoing != nil && self.hasProgressed(&loopProgress) let lifetimeSpecifierArgumentList = RawLifetimeSpecifierArgumentListSyntax(elements: arguments, arena: self.arena) let (unexpectedBeforeRightParen, rightParen) = self.expect(.rightParen) - let argumentsSyntax = RawLifetimeSpecifierArgumentsSyntax( - arguments: lifetimeSpecifierArgumentList, - arena: self.arena - ) let lifetimeSpecifier = RawLifetimeTypeSpecifierSyntax( - dependsOnKeyword: specifier, + unexpectedBeforeDependsOnKeyword, + dependsOnKeyword: dependsOnKeyword, leftParen: leftParen, scopedKeyword: scoped, - arguments: argumentsSyntax, + arguments: lifetimeSpecifierArgumentList, unexpectedBeforeRightParen, rightParen: rightParen, arena: self.arena @@ -981,7 +976,7 @@ extension Parser { SPECIFIER_PARSING: while canHaveParameterSpecifier { if let (_, specifierHandle) = self.at(anyIn: SimpleTypeSpecifierSyntax.SpecifierOptions.self) { specifiers.append(parseSimpleTypeSpecifier(specifierHandle: specifierHandle)) - } else if self.at(TokenSpec(.dependsOn)) { + } else if self.at(.keyword(.dependsOn)) { if self.experimentalFeatures.contains(.nonescapableTypes) { specifiers.append(parseLifetimeTypeSpecifier()) } else { diff --git a/Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift b/Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift index b2666dca2a3..adec42bc2ca 100644 --- a/Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift +++ b/Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift @@ -2009,12 +2009,6 @@ public func childName(_ keyPath: AnyKeyPath) -> String? { return "trailingComma" case \LifetimeSpecifierArgumentSyntax.unexpectedAfterTrailingComma: return "unexpectedAfterTrailingComma" - case \LifetimeSpecifierArgumentsSyntax.unexpectedBeforeArguments: - return "unexpectedBeforeArguments" - case \LifetimeSpecifierArgumentsSyntax.arguments: - return "arguments" - case \LifetimeSpecifierArgumentsSyntax.unexpectedAfterArguments: - return "unexpectedAfterArguments" case \LifetimeTypeSpecifierSyntax.unexpectedBeforeDependsOnKeyword: return "unexpectedBeforeDependsOnKeyword" case \LifetimeTypeSpecifierSyntax.dependsOnKeyword: diff --git a/Sources/SwiftSyntax/generated/SyntaxAnyVisitor.swift b/Sources/SwiftSyntax/generated/SyntaxAnyVisitor.swift index 17eb0b51b3e..83bef83ebef 100644 --- a/Sources/SwiftSyntax/generated/SyntaxAnyVisitor.swift +++ b/Sources/SwiftSyntax/generated/SyntaxAnyVisitor.swift @@ -1374,20 +1374,6 @@ open class SyntaxAnyVisitor: SyntaxVisitor { visitAnyPost(node._syntaxNode) } - #if compiler(>=5.8) - @_spi(ExperimentalLanguageFeatures) - #endif - override open func visit(_ node: LifetimeSpecifierArgumentsSyntax) -> SyntaxVisitorContinueKind { - return visitAny(node._syntaxNode) - } - - #if compiler(>=5.8) - @_spi(ExperimentalLanguageFeatures) - #endif - override open func visitPost(_ node: LifetimeSpecifierArgumentsSyntax) { - visitAnyPost(node._syntaxNode) - } - #if compiler(>=5.8) @_spi(ExperimentalLanguageFeatures) #endif diff --git a/Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift b/Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift index 7ff75ce92c4..e5cd0600dc2 100644 --- a/Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift +++ b/Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift @@ -1681,7 +1681,6 @@ extension Syntax { .node(LayoutRequirementSyntax.self), .node(LifetimeSpecifierArgumentListSyntax.self), .node(LifetimeSpecifierArgumentSyntax.self), - .node(LifetimeSpecifierArgumentsSyntax.self), .node(LifetimeTypeSpecifierSyntax.self), .node(MacroDeclSyntax.self), .node(MacroExpansionDeclSyntax.self), diff --git a/Sources/SwiftSyntax/generated/SyntaxEnum.swift b/Sources/SwiftSyntax/generated/SyntaxEnum.swift index cf24a56b678..0654f834647 100644 --- a/Sources/SwiftSyntax/generated/SyntaxEnum.swift +++ b/Sources/SwiftSyntax/generated/SyntaxEnum.swift @@ -191,10 +191,6 @@ public enum SyntaxEnum: Sendable { #if compiler(>=5.8) @_spi(ExperimentalLanguageFeatures) #endif - case lifetimeSpecifierArguments(LifetimeSpecifierArgumentsSyntax) - #if compiler(>=5.8) - @_spi(ExperimentalLanguageFeatures) - #endif case lifetimeTypeSpecifier(LifetimeTypeSpecifierSyntax) case macroDecl(MacroDeclSyntax) case macroExpansionDecl(MacroExpansionDeclSyntax) @@ -651,8 +647,6 @@ public extension Syntax { return .lifetimeSpecifierArgumentList(LifetimeSpecifierArgumentListSyntax(self)!) case .lifetimeSpecifierArgument: return .lifetimeSpecifierArgument(LifetimeSpecifierArgumentSyntax(self)!) - case .lifetimeSpecifierArguments: - return .lifetimeSpecifierArguments(LifetimeSpecifierArgumentsSyntax(self)!) case .lifetimeTypeSpecifier: return .lifetimeTypeSpecifier(LifetimeTypeSpecifierSyntax(self)!) case .macroDecl: diff --git a/Sources/SwiftSyntax/generated/SyntaxKind.swift b/Sources/SwiftSyntax/generated/SyntaxKind.swift index 3724843f407..05829bf445b 100644 --- a/Sources/SwiftSyntax/generated/SyntaxKind.swift +++ b/Sources/SwiftSyntax/generated/SyntaxKind.swift @@ -191,10 +191,6 @@ public enum SyntaxKind: Sendable { #if compiler(>=5.8) @_spi(ExperimentalLanguageFeatures) #endif - case lifetimeSpecifierArguments - #if compiler(>=5.8) - @_spi(ExperimentalLanguageFeatures) - #endif case lifetimeTypeSpecifier case macroDecl case macroExpansionDecl @@ -776,8 +772,6 @@ public enum SyntaxKind: Sendable { return LifetimeSpecifierArgumentListSyntax.self case .lifetimeSpecifierArgument: return LifetimeSpecifierArgumentSyntax.self - case .lifetimeSpecifierArguments: - return LifetimeSpecifierArgumentsSyntax.self case .lifetimeTypeSpecifier: return LifetimeTypeSpecifierSyntax.self case .macroDecl: diff --git a/Sources/SwiftSyntax/generated/SyntaxRewriter.swift b/Sources/SwiftSyntax/generated/SyntaxRewriter.swift index e3b3b26d480..7a2bb82f013 100644 --- a/Sources/SwiftSyntax/generated/SyntaxRewriter.swift +++ b/Sources/SwiftSyntax/generated/SyntaxRewriter.swift @@ -1225,16 +1225,6 @@ open class SyntaxRewriter { return visitChildren(node) } - /// Visit a `LifetimeSpecifierArgumentsSyntax`. - /// - Parameter node: the node that is being visited - /// - Returns: the rewritten node - #if compiler(>=5.8) - @_spi(ExperimentalLanguageFeatures) - #endif - open func visit(_ node: LifetimeSpecifierArgumentsSyntax) -> LifetimeSpecifierArgumentsSyntax { - return visitChildren(node) - } - /// Visit a `LifetimeTypeSpecifierSyntax`. /// - Parameter node: the node that is being visited /// - Returns: the rewritten node @@ -2820,10 +2810,6 @@ open class SyntaxRewriter { return { self.visitImpl($0, LifetimeSpecifierArgumentSyntax.self, self.visit) } - case .lifetimeSpecifierArguments: - return { - self.visitImpl($0, LifetimeSpecifierArgumentsSyntax.self, self.visit) - } case .lifetimeTypeSpecifier: return { self.visitImpl($0, LifetimeTypeSpecifierSyntax.self, self.visit) @@ -3642,8 +3628,6 @@ open class SyntaxRewriter { return visitImpl(node, LifetimeSpecifierArgumentListSyntax.self, visit) case .lifetimeSpecifierArgument: return visitImpl(node, LifetimeSpecifierArgumentSyntax.self, visit) - case .lifetimeSpecifierArguments: - return visitImpl(node, LifetimeSpecifierArgumentsSyntax.self, visit) case .lifetimeTypeSpecifier: return visitImpl(node, LifetimeTypeSpecifierSyntax.self, visit) case .macroDecl: diff --git a/Sources/SwiftSyntax/generated/SyntaxTraits.swift b/Sources/SwiftSyntax/generated/SyntaxTraits.swift index e842583feb6..1034e136ffc 100644 --- a/Sources/SwiftSyntax/generated/SyntaxTraits.swift +++ b/Sources/SwiftSyntax/generated/SyntaxTraits.swift @@ -779,8 +779,6 @@ extension LabeledSpecializeArgumentSyntax: WithTrailingCommaSyntax {} extension LifetimeSpecifierArgumentSyntax: WithTrailingCommaSyntax {} -extension LifetimeTypeSpecifierSyntax: ParenthesizedSyntax {} - extension MacroDeclSyntax: NamedDeclSyntax, WithAttributesSyntax, WithGenericParametersSyntax, WithModifiersSyntax {} extension MacroExpansionDeclSyntax: FreestandingMacroExpansionSyntax, WithAttributesSyntax, WithModifiersSyntax {} diff --git a/Sources/SwiftSyntax/generated/SyntaxVisitor.swift b/Sources/SwiftSyntax/generated/SyntaxVisitor.swift index 80a4de49214..4468b10c27b 100644 --- a/Sources/SwiftSyntax/generated/SyntaxVisitor.swift +++ b/Sources/SwiftSyntax/generated/SyntaxVisitor.swift @@ -2019,24 +2019,6 @@ open class SyntaxVisitor { open func visitPost(_ node: LifetimeSpecifierArgumentSyntax) { } - /// Visiting `LifetimeSpecifierArgumentsSyntax` specifically. - /// - Parameter node: the node we are visiting. - /// - Returns: how should we continue visiting. - #if compiler(>=5.8) - @_spi(ExperimentalLanguageFeatures) - #endif - open func visit(_ node: LifetimeSpecifierArgumentsSyntax) -> SyntaxVisitorContinueKind { - return .visitChildren - } - - /// The function called after visiting `LifetimeSpecifierArgumentsSyntax` and its descendants. - /// - node: the node we just finished visiting. - #if compiler(>=5.8) - @_spi(ExperimentalLanguageFeatures) - #endif - open func visitPost(_ node: LifetimeSpecifierArgumentsSyntax) { - } - /// Visiting `LifetimeTypeSpecifierSyntax` specifically. /// - Parameter node: the node we are visiting. /// - Returns: how should we continue visiting. @@ -4220,10 +4202,6 @@ open class SyntaxVisitor { return { self.visitImpl(&$0, LifetimeSpecifierArgumentSyntax.self, self.visit, self.visitPost) } - case .lifetimeSpecifierArguments: - return { - self.visitImpl(&$0, LifetimeSpecifierArgumentsSyntax.self, self.visit, self.visitPost) - } case .lifetimeTypeSpecifier: return { self.visitImpl(&$0, LifetimeTypeSpecifierSyntax.self, self.visit, self.visitPost) @@ -5046,8 +5024,6 @@ open class SyntaxVisitor { visitImpl(&node, LifetimeSpecifierArgumentListSyntax.self, visit, visitPost) case .lifetimeSpecifierArgument: visitImpl(&node, LifetimeSpecifierArgumentSyntax.self, visit, visitPost) - case .lifetimeSpecifierArguments: - visitImpl(&node, LifetimeSpecifierArgumentsSyntax.self, visit, visitPost) case .lifetimeTypeSpecifier: visitImpl(&node, LifetimeTypeSpecifierSyntax.self, visit, visitPost) case .macroDecl: diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesJKLMN.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesJKLMN.swift index 56087afd1f9..18adc64115b 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesJKLMN.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxNodesJKLMN.swift @@ -1049,67 +1049,6 @@ public struct RawLifetimeSpecifierArgumentSyntax: RawSyntaxNodeProtocol { } } -#if compiler(>=5.8) -@_spi(ExperimentalLanguageFeatures) -#endif -@_spi(RawSyntax) -public struct RawLifetimeSpecifierArgumentsSyntax: RawSyntaxNodeProtocol { - @_spi(RawSyntax) - public var layoutView: RawSyntaxLayoutView { - return raw.layoutView! - } - - public static func isKindOf(_ raw: RawSyntax) -> Bool { - return raw.kind == .lifetimeSpecifierArguments - } - - public var raw: RawSyntax - - init(raw: RawSyntax) { - precondition(Self.isKindOf(raw)) - self.raw = raw - } - - private init(unchecked raw: RawSyntax) { - self.raw = raw - } - - public init?(_ other: some RawSyntaxNodeProtocol) { - guard Self.isKindOf(other.raw) else { - return nil - } - self.init(unchecked: other.raw) - } - - public init( - _ unexpectedBeforeArguments: RawUnexpectedNodesSyntax? = nil, - arguments: RawLifetimeSpecifierArgumentListSyntax, - _ unexpectedAfterArguments: RawUnexpectedNodesSyntax? = nil, - arena: __shared SyntaxArena - ) { - let raw = RawSyntax.makeLayout( - kind: .lifetimeSpecifierArguments, uninitializedCount: 3, arena: arena) { layout in - layout.initialize(repeating: nil) - layout[0] = unexpectedBeforeArguments?.raw - layout[1] = arguments.raw - layout[2] = unexpectedAfterArguments?.raw - } - self.init(unchecked: raw) - } - - public var unexpectedBeforeArguments: RawUnexpectedNodesSyntax? { - layoutView.children[0].map(RawUnexpectedNodesSyntax.init(raw:)) - } - - public var arguments: RawLifetimeSpecifierArgumentListSyntax { - layoutView.children[1].map(RawLifetimeSpecifierArgumentListSyntax.init(raw:))! - } - - public var unexpectedAfterArguments: RawUnexpectedNodesSyntax? { - layoutView.children[2].map(RawUnexpectedNodesSyntax.init(raw:)) - } -} - #if compiler(>=5.8) @_spi(ExperimentalLanguageFeatures) #endif @@ -1150,7 +1089,7 @@ public struct RawLifetimeTypeSpecifierSyntax: RawSyntaxNodeProtocol { _ unexpectedBetweenLeftParenAndScopedKeyword: RawUnexpectedNodesSyntax? = nil, scopedKeyword: RawTokenSyntax?, _ unexpectedBetweenScopedKeywordAndArguments: RawUnexpectedNodesSyntax? = nil, - arguments: RawLifetimeSpecifierArgumentsSyntax, + arguments: RawLifetimeSpecifierArgumentListSyntax, _ unexpectedBetweenArgumentsAndRightParen: RawUnexpectedNodesSyntax? = nil, rightParen: RawTokenSyntax, _ unexpectedAfterRightParen: RawUnexpectedNodesSyntax? = nil, @@ -1202,8 +1141,8 @@ public struct RawLifetimeTypeSpecifierSyntax: RawSyntaxNodeProtocol { layoutView.children[6].map(RawUnexpectedNodesSyntax.init(raw:)) } - public var arguments: RawLifetimeSpecifierArgumentsSyntax { - layoutView.children[7].map(RawLifetimeSpecifierArgumentsSyntax.init(raw:))! + public var arguments: RawLifetimeSpecifierArgumentListSyntax { + layoutView.children[7].map(RawLifetimeSpecifierArgumentListSyntax.init(raw:))! } public var unexpectedBetweenArgumentsAndRightParen: RawUnexpectedNodesSyntax? { diff --git a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift index 7a685aa4bb8..31ef04df6dd 100644 --- a/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift +++ b/Sources/SwiftSyntax/generated/raw/RawSyntaxValidation.swift @@ -1725,11 +1725,6 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 3, verify(layout[3], as: RawTokenSyntax?.self, tokenChoices: [.tokenKind(.comma)])) assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) - case .lifetimeSpecifierArguments: - assert(layout.count == 3) - assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 1, verify(layout[1], as: RawLifetimeSpecifierArgumentListSyntax.self)) - assertNoError(kind, 2, verify(layout[2], as: RawUnexpectedNodesSyntax?.self)) case .lifetimeTypeSpecifier: assert(layout.count == 11) assertNoError(kind, 0, verify(layout[0], as: RawUnexpectedNodesSyntax?.self)) @@ -1739,7 +1734,7 @@ func validateLayout(layout: RawSyntaxBuffer, as kind: SyntaxKind) { assertNoError(kind, 4, verify(layout[4], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 5, verify(layout[5], as: RawTokenSyntax?.self, tokenChoices: [.keyword("scoped")])) assertNoError(kind, 6, verify(layout[6], as: RawUnexpectedNodesSyntax?.self)) - assertNoError(kind, 7, verify(layout[7], as: RawLifetimeSpecifierArgumentsSyntax.self)) + assertNoError(kind, 7, verify(layout[7], as: RawLifetimeSpecifierArgumentListSyntax.self)) assertNoError(kind, 8, verify(layout[8], as: RawUnexpectedNodesSyntax?.self)) assertNoError(kind, 9, verify(layout[9], as: RawTokenSyntax.self, tokenChoices: [.tokenKind(.rightParen)])) assertNoError(kind, 10, verify(layout[10], as: RawUnexpectedNodesSyntax?.self)) diff --git a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesJKLMN.swift b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesJKLMN.swift index 9f02ec31ce5..9db4ef199ab 100644 --- a/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesJKLMN.swift +++ b/Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesJKLMN.swift @@ -1790,119 +1790,6 @@ public struct LifetimeSpecifierArgumentSyntax: SyntaxProtocol, SyntaxHashable, _ } } -// MARK: - LifetimeSpecifierArgumentsSyntax - -/// An optional argument passed to a type parameter. -/// -/// ### Example -/// `borrow(data)` in `func foo(data: Array) -> borrow(data) ComplexReferenceType` -/// -/// - Experiment: Requires experimental feature `nonescapableTypes`. -/// -/// ### Children -/// -/// - `arguments`: `LifetimeSpecifierArgumentListSyntax` -#if compiler(>=5.8) -@_spi(ExperimentalLanguageFeatures) -#endif -public struct LifetimeSpecifierArgumentsSyntax: SyntaxProtocol, SyntaxHashable, _LeafSyntaxNodeProtocol { - public let _syntaxNode: Syntax - - public init?(_ node: some SyntaxProtocol) { - guard node.raw.kind == .lifetimeSpecifierArguments else { - return nil - } - self._syntaxNode = node._syntaxNode - } - - /// - Parameters: - /// - leadingTrivia: Trivia to be prepended to the leading trivia of the node’s first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. - /// - arguments: The function parameters that the lifetime of the annotated type depends on. - /// - trailingTrivia: Trivia to be appended to the trailing trivia of the node’s last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. - public init( - leadingTrivia: Trivia? = nil, - _ unexpectedBeforeArguments: UnexpectedNodesSyntax? = nil, - arguments: LifetimeSpecifierArgumentListSyntax, - _ unexpectedAfterArguments: UnexpectedNodesSyntax? = nil, - trailingTrivia: Trivia? = nil - - ) { - // Extend the lifetime of all parameters so their arenas don't get destroyed - // before they can be added as children of the new arena. - self = withExtendedLifetime((SyntaxArena(), (unexpectedBeforeArguments, arguments, unexpectedAfterArguments))) { (arena, _) in - let layout: [RawSyntax?] = [unexpectedBeforeArguments?.raw, arguments.raw, unexpectedAfterArguments?.raw] - let raw = RawSyntax.makeLayout( - kind: SyntaxKind.lifetimeSpecifierArguments, - from: layout, - arena: arena, - leadingTrivia: leadingTrivia, - trailingTrivia: trailingTrivia - - ) - return Syntax.forRoot(raw, rawNodeArena: arena).cast(Self.self) - } - } - - public var unexpectedBeforeArguments: UnexpectedNodesSyntax? { - get { - return Syntax(self).child(at: 0)?.cast(UnexpectedNodesSyntax.self) - } - set(value) { - self = Syntax(self).replacingChild(at: 0, with: Syntax(value), arena: SyntaxArena()).cast(LifetimeSpecifierArgumentsSyntax.self) - } - } - - /// The function parameters that the lifetime of the annotated type depends on. - public var arguments: LifetimeSpecifierArgumentListSyntax { - get { - return Syntax(self).child(at: 1)!.cast(LifetimeSpecifierArgumentListSyntax.self) - } - set(value) { - self = Syntax(self).replacingChild(at: 1, with: Syntax(value), arena: SyntaxArena()).cast(LifetimeSpecifierArgumentsSyntax.self) - } - } - - /// Adds the provided `element` to the node's `arguments` - /// collection. - /// - /// - param element: The new `Arguments` to add to the node's - /// `arguments` collection. - /// - returns: A copy of the receiver with the provided `Arguments` - /// appended to its `arguments` collection. - @available(*, deprecated, message: "Use node.arguments.append(newElement) instead") - public func addArguments(_ element: LifetimeSpecifierArgumentSyntax) -> LifetimeSpecifierArgumentsSyntax { - var collection: RawSyntax - let arena = SyntaxArena() - if let col = raw.layoutView!.children[1] { - collection = col.layoutView!.appending(element.raw, arena: arena) - } else { - collection = RawSyntax.makeLayout(kind: SyntaxKind.lifetimeSpecifierArgumentList, - from: [element.raw], arena: arena) - } - return Syntax(self) - .replacingChild( - at: 1, - with: collection, - rawNodeArena: arena, - allocationArena: arena - ) - .cast(LifetimeSpecifierArgumentsSyntax.self) - } - - public var unexpectedAfterArguments: UnexpectedNodesSyntax? { - get { - return Syntax(self).child(at: 2)?.cast(UnexpectedNodesSyntax.self) - } - set(value) { - self = Syntax(self).replacingChild(at: 2, with: Syntax(value), arena: SyntaxArena()).cast(LifetimeSpecifierArgumentsSyntax.self) - } - } - - public static var structure: SyntaxNodeStructure { - return .layout([\Self.unexpectedBeforeArguments, \Self.arguments, \Self.unexpectedAfterArguments]) - } -} - // MARK: - LifetimeTypeSpecifierSyntax /// A specifier that specifies function parameter on whose lifetime a type depends @@ -1914,7 +1801,7 @@ public struct LifetimeSpecifierArgumentsSyntax: SyntaxProtocol, SyntaxHashable, /// - `dependsOnKeyword`: `dependsOn` /// - `leftParen`: `(` /// - `scopedKeyword`: `scoped`? -/// - `arguments`: `LifetimeSpecifierArgumentsSyntax` +/// - `arguments`: `LifetimeSpecifierArgumentListSyntax` /// - `rightParen`: `)` /// /// ### Contained in @@ -1935,7 +1822,8 @@ public struct LifetimeTypeSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _Leaf /// - Parameters: /// - leadingTrivia: Trivia to be prepended to the leading trivia of the node’s first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. - /// - dependsOnKeyword: The specifier token that's attached to the type. + /// - dependsOnKeyword: lifetime dependence specifier on the return type + /// - scopedKeyword: lifetime of return value is scoped to the lifetime of the original value /// - trailingTrivia: Trivia to be appended to the trailing trivia of the node’s last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored. public init( leadingTrivia: Trivia? = nil, @@ -1946,7 +1834,7 @@ public struct LifetimeTypeSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _Leaf _ unexpectedBetweenLeftParenAndScopedKeyword: UnexpectedNodesSyntax? = nil, scopedKeyword: TokenSyntax? = nil, _ unexpectedBetweenScopedKeywordAndArguments: UnexpectedNodesSyntax? = nil, - arguments: LifetimeSpecifierArgumentsSyntax, + arguments: LifetimeSpecifierArgumentListSyntax, _ unexpectedBetweenArgumentsAndRightParen: UnexpectedNodesSyntax? = nil, rightParen: TokenSyntax = .rightParenToken(), _ unexpectedAfterRightParen: UnexpectedNodesSyntax? = nil, @@ -2002,7 +1890,7 @@ public struct LifetimeTypeSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _Leaf } } - /// The specifier token that's attached to the type. + /// lifetime dependence specifier on the return type /// /// ### Tokens /// @@ -2046,6 +1934,8 @@ public struct LifetimeTypeSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _Leaf } } + /// lifetime of return value is scoped to the lifetime of the original value + /// /// ### Tokens /// /// For syntax trees generated by the parser, this is guaranteed to be `scoped`. @@ -2067,15 +1957,42 @@ public struct LifetimeTypeSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _Leaf } } - public var arguments: LifetimeSpecifierArgumentsSyntax { + public var arguments: LifetimeSpecifierArgumentListSyntax { get { - return Syntax(self).child(at: 7)!.cast(LifetimeSpecifierArgumentsSyntax.self) + return Syntax(self).child(at: 7)!.cast(LifetimeSpecifierArgumentListSyntax.self) } set(value) { self = Syntax(self).replacingChild(at: 7, with: Syntax(value), arena: SyntaxArena()).cast(LifetimeTypeSpecifierSyntax.self) } } + /// Adds the provided `element` to the node's `arguments` + /// collection. + /// + /// - param element: The new `Arguments` to add to the node's + /// `arguments` collection. + /// - returns: A copy of the receiver with the provided `Arguments` + /// appended to its `arguments` collection. + @available(*, deprecated, message: "Use node.arguments.append(newElement) instead") + public func addArguments(_ element: LifetimeSpecifierArgumentSyntax) -> LifetimeTypeSpecifierSyntax { + var collection: RawSyntax + let arena = SyntaxArena() + if let col = raw.layoutView!.children[7] { + collection = col.layoutView!.appending(element.raw, arena: arena) + } else { + collection = RawSyntax.makeLayout(kind: SyntaxKind.lifetimeSpecifierArgumentList, + from: [element.raw], arena: arena) + } + return Syntax(self) + .replacingChild( + at: 7, + with: collection, + rawNodeArena: arena, + allocationArena: arena + ) + .cast(LifetimeTypeSpecifierSyntax.self) + } + public var unexpectedBetweenArgumentsAndRightParen: UnexpectedNodesSyntax? { get { return Syntax(self).child(at: 8)?.cast(UnexpectedNodesSyntax.self)