RFC: Remove several special attribute argument list syntax

Link to PR: [Syntax] Remove unnecessary special attribute arguments syntax kinds by rintaro · Pull Request #3028 · swiftlang/swift-syntax · GitHub
Summary: Several builtin attributes that currently has specialized argument list syntax. But they actually can be parsed and represented with regular AttributeSyntax.Argument.argumentList(LabeledExprListSyntax). Since special attribute syntax doesn't give us much benefit other than the slight possibility of some specialized parser diangnostics, I propose to remove them and use more generalized LabeledExprListSyntax

API changes:

  • Remove ConventionAttributeArgumentsSyntax, ConventionWitnessMethodAttributeArgumentsSyntax, OpaqueReturnTypeOfAttributeArgumentsSyntax, ExposeAttributeArgumentsSyntax, UnderscorePrivateAttributeArgumentsSyntax, and UnavailableFromAsyncAttributeArgumentsSyntax.
  • Remove cases from AttributeSyntax.Arguments: token(TokenSyntax), string(StringLiteralExprSyntax), conventionArguments(ConventionAttributeArgumentsSyntax), conventionWitnessMethodArguments(ConventionWitnessMethodAttributeArgumentsSyntax), opaqueReturnTypeOfAttributeArguments(OpaqueReturnTypeOfAttributeArgumentsSyntax), exposeAttributeArguments(ExposeAttributeArgumentsSyntax), underscorePrivateAttributeArguments(UnderscorePrivateAttributeArgumentsSyntax), and unavailableFromAsyncArguments(UnavailableFromAsyncAttributeArgumentsSyntax)
  • Remove several Keyword kind just for those types.

Migration: Those arguments are now parsed as LabeledExprListSyntax. SyntaxParser clients can use .argumentList case to extract the arguments. For SwiftSyntax/SwiftSyntaxBuilder users who are using those specialized syntax can migrate to LabeledExprListSyntax.

Removing these is a great clean up for me.

2 Likes

swift-format has a lot of code to handle these special cases in the pretty printer, when all it's really doing is giving them the same formatting that argument-list-based attributes would have. It would be great to be able to remove all of that.

Anything built-in that can be represented as a regular argument list should be.

1 Like

Swift Testing will need to stage in the relevant changes, so please ensure old symbols/names remain functional.

1 Like