Skip to content

Make @abi non-experimental #3065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ public let ATTRIBUTE_NODES: [Node] = [
Child(
name: "abiArguments",
// Special arguments for declaration syntax. e.g. @abi(func abiName() -> Int)
kind: .node(kind: .abiAttributeArguments),
experimentalFeature: .abiAttribute
kind: .node(kind: .abiAttributeArguments)
),
]),
documentation: """
Expand Down Expand Up @@ -256,7 +255,6 @@ public let ATTRIBUTE_NODES: [Node] = [
Node(
kind: .abiAttributeArguments,
base: .syntax,
experimentalFeature: .abiAttribute,
nameForDiagnostics: "ABI-providing declaration",
documentation: "The arguments of the '@abi' attribute",
children: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public enum ExperimentalFeature: String, CaseIterable {
case nonescapableTypes
case trailingComma
case coroutineAccessors
case abiAttribute
case keypathWithMethodMembers
case oldOwnershipOperatorSpellings
case inlineArrayTypeSugar
Expand All @@ -39,8 +38,6 @@ public enum ExperimentalFeature: String, CaseIterable {
return "TrailingComma"
case .coroutineAccessors:
return "CoroutineAccessors"
case .abiAttribute:
return "ABIAttribute"
case .keypathWithMethodMembers:
return "KeypathWithMethodMembers"
case .oldOwnershipOperatorSpellings:
Expand All @@ -65,8 +62,6 @@ public enum ExperimentalFeature: String, CaseIterable {
return "trailing commas"
case .coroutineAccessors:
return "coroutine accessors"
case .abiAttribute:
return "@abi attribute"
case .keypathWithMethodMembers:
return "keypaths with method members"
case .oldOwnershipOperatorSpellings:
Expand Down
2 changes: 1 addition & 1 deletion CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public enum Keyword: CaseIterable {
case ._version:
return KeywordSpec("_version")
case .abi:
return KeywordSpec("abi", experimentalFeature: .abiAttribute)
return KeywordSpec("abi")
case .accesses:
return KeywordSpec("accesses")
case .actor:
Expand Down
24 changes: 8 additions & 16 deletions Sources/SwiftParser/Attributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ extension Parser {
switch peek(isAtAnyIn: DeclarationAttributeWithSpecialSyntax.self) {
case .abi:
return parseAttribute(argumentMode: .required) { parser in
return parser.parseABIAttributeArguments()
return (nil, .abiArguments(parser.parseABIAttributeArguments()))
} parseMissingArguments: { parser in
return parser.parseABIAttributeArguments(missingLParen: true)
return (nil, .abiArguments(parser.parseABIAttributeArguments(missingLParen: true)))
}
case .available, ._spi_available:
return parseAttribute(argumentMode: .required) { parser in
Expand Down Expand Up @@ -794,9 +794,9 @@ extension Parser {
/// - Parameter missingLParen: `true` if the opening paren for the argument list was missing.
mutating func parseABIAttributeArguments(
missingLParen: Bool = false
) -> (RawUnexpectedNodesSyntax?, RawAttributeSyntax.Arguments) {
func makeMissingProviderArguments(unexpectedBefore: [RawSyntax]) -> RawAttributeSyntax.Arguments {
let args = RawABIAttributeArgumentsSyntax(
) -> RawABIAttributeArgumentsSyntax {
func makeMissingProviderArguments(unexpectedBefore: [RawSyntax]) -> RawABIAttributeArgumentsSyntax {
return RawABIAttributeArgumentsSyntax(
provider: .missing(
RawMissingDeclSyntax(
unexpectedBefore.isEmpty ? nil : RawUnexpectedNodesSyntax(elements: unexpectedBefore, arena: self.arena),
Expand All @@ -808,7 +808,6 @@ extension Parser {
),
arena: self.arena
)
return .abiArguments(args)
}

// Consider the three kinds of mistakes we might see here:
Expand All @@ -824,23 +823,16 @@ extension Parser {
// In lieu of that, we judge that recovering gracefully from #3 is more important than #2 and therefore do not even
// attempt to parse the argument unless we've seen a left paren.
guard !missingLParen && !self.at(.rightParen) else {
return (nil, makeMissingProviderArguments(unexpectedBefore: []))
return makeMissingProviderArguments(unexpectedBefore: [])
}

let decl = parseDeclaration(in: .argumentList)

guard experimentalFeatures.contains(.abiAttribute) else {
return (
RawUnexpectedNodesSyntax([decl], arena: self.arena),
.argumentList(RawLabeledExprListSyntax(elements: [], arena: self.arena))
)
}

guard let provider = RawABIAttributeArgumentsSyntax.Provider(decl) else {
return (nil, makeMissingProviderArguments(unexpectedBefore: [decl.raw]))
return makeMissingProviderArguments(unexpectedBefore: [decl.raw])
}

return (nil, .abiArguments(RawABIAttributeArgumentsSyntax(provider: provider, arena: self.arena)))
return RawABIAttributeArgumentsSyntax(provider: provider, arena: self.arena)
}
}

Expand Down
11 changes: 3 additions & 8 deletions Sources/SwiftParser/generated/ExperimentalFeatures.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Sources/SwiftSyntax/generated/Keyword.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Sources/SwiftSyntax/generated/SyntaxAnyVisitor.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Sources/SwiftSyntax/generated/SyntaxEnum.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Sources/SwiftSyntax/generated/SyntaxKind.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Sources/SwiftSyntax/generated/SyntaxRewriter.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions Sources/SwiftSyntax/generated/SyntaxVisitor.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Sources/SwiftSyntax/generated/raw/RawSyntaxNodesAB.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 10 additions & 19 deletions Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesAB.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading