@@ -495,7 +495,9 @@ extension Parser {
495495 let colon : RawTokenSyntax ?
496496 var misplacedSpecifiers : [ RawTokenSyntax ] = [ ]
497497 if self . withLookahead ( { $0. startsParameterName ( isClosure: false , allowMisplacedSpecifierRecovery: true ) } ) {
498- while let specifier = self . consume ( ifAnyIn: TypeSpecifier . self) {
498+ while canHaveParameterSpecifier,
499+ let specifier = self . consume ( ifAnyIn: TypeSpecifier . self)
500+ {
499501 misplacedSpecifiers. append ( specifier)
500502 }
501503 ( unexpectedBeforeFirst, first) = self . parseArgumentLabel ( )
@@ -657,7 +659,8 @@ extension Parser.Lookahead {
657659 mutating func skipTypeAttributeList( ) {
658660 var specifierProgress = LoopProgressCondition ( )
659661 // TODO: Can we model isolated/_const so that they're specified in both canParse* and parse*?
660- while self . at ( anyIn: TypeSpecifier . self) != nil || self . at ( . keyword( . isolated) ) || self . at ( . keyword( . _const) ) ,
662+ while canHaveParameterSpecifier,
663+ self . at ( anyIn: TypeSpecifier . self) != nil || self . at ( . keyword( . isolated) ) || self . at ( . keyword( . _const) ) ,
661664 specifierProgress. evaluate ( currentToken)
662665 {
663666 self . consumeAnyToken ( )
@@ -924,7 +927,10 @@ extension Parser {
924927 public mutating func parseTypeAttributeList( misplacedSpecifiers: [ RawTokenSyntax ] = [ ] ) -> (
925928 specifier: RawTokenSyntax ? , unexpectedBeforeAttributes: RawUnexpectedNodesSyntax ? , attributes: RawAttributeListSyntax ?
926929 ) {
927- var specifier : RawTokenSyntax ? = self . consume ( ifAnyIn: TypeSpecifier . self)
930+ var specifier : RawTokenSyntax ? = nil
931+ if canHaveParameterSpecifier {
932+ specifier = self . consume ( ifAnyIn: TypeSpecifier . self)
933+ }
928934 // We can only stick one specifier on this type. Let's pick the first one
929935 if specifier == nil , let misplacedSpecifier = misplacedSpecifiers. first {
930936 specifier = missingToken ( misplacedSpecifier. tokenKind, text: misplacedSpecifier. tokenText)
@@ -937,6 +943,8 @@ extension Parser {
937943 case __owned
938944 case isolated
939945 case _const
946+ case consuming
947+ case borrowing
940948
941949 var spec : TokenSpec {
942950 switch self {
@@ -945,6 +953,8 @@ extension Parser {
945953 case . __owned: return . keyword( . __owned)
946954 case . isolated: return . keyword( . isolated)
947955 case . _const: return . keyword( . _const)
956+ case . consuming: return . keyword( . consuming)
957+ case . borrowing: return . keyword( . borrowing)
948958 }
949959 }
950960
@@ -955,12 +965,16 @@ extension Parser {
955965 case TokenSpec ( . __owned) : self = . __owned
956966 case TokenSpec ( . isolated) : self = . isolated
957967 case TokenSpec ( . _const) : self = . _const
968+ case TokenSpec ( . consuming) : self = . consuming
969+ case TokenSpec ( . borrowing) : self = . borrowing
958970 default : return nil
959971 }
960972 }
961973 }
962974
963- while let extraSpecifier = self . consume ( ifAnyIn: ExtraneousSpecifier . self) {
975+ while canHaveParameterSpecifier,
976+ let extraSpecifier = self . consume ( ifAnyIn: ExtraneousSpecifier . self)
977+ {
964978 if specifier == nil {
965979 specifier = extraSpecifier
966980 } else {
0 commit comments