@@ -900,33 +900,31 @@ extension Parser.Lookahead {
900900}
901901
902902extension Parser {
903- private mutating func parseLifetimeTypeSpecifier(
904- specifierHandle: TokenConsumptionHandle
905- ) -> RawTypeSpecifierListSyntax . Element {
906- let specifier = self . eat ( specifierHandle)
903+ private mutating func parseLifetimeTypeSpecifier( ) -> RawTypeSpecifierListSyntax . Element {
904+ let ( unexpectedBeforeDependsOnKeyword, dependsOnKeyword) = self . expect ( . keyword( . dependsOn) )
907905
908906 guard let leftParen = self . consume ( if: . leftParen) else {
909907 // If there is no left paren, add an entirely missing detail. Otherwise, we start to consume the following type
910908 // name as a token inside the detail, which leads to confusing recovery results.
911- let arguments = RawLifetimeSpecifierArgumentsSyntax (
912- leftParen: missingToken ( . leftParen) ,
913- arguments: RawLifetimeSpecifierArgumentListSyntax (
914- elements: [
915- RawLifetimeSpecifierArgumentSyntax ( parameter: missingToken ( . identifier) , trailingComma: nil , arena: arena)
916- ] ,
917- arena: self . arena
918- ) ,
919- rightParen: missingToken ( . rightParen) ,
909+ let lifetimeSpecifierArgumentList = RawLifetimeSpecifierArgumentListSyntax (
910+ elements: [
911+ RawLifetimeSpecifierArgumentSyntax ( parameter: missingToken ( . identifier) , trailingComma: nil , arena: arena)
912+ ] ,
920913 arena: self . arena
921914 )
922915 let lifetimeSpecifier = RawLifetimeTypeSpecifierSyntax (
923- specifier: specifier,
924- arguments: arguments,
916+ unexpectedBeforeDependsOnKeyword,
917+ dependsOnKeyword: dependsOnKeyword,
918+ leftParen: missingToken ( . leftParen) ,
919+ scopedKeyword: nil ,
920+ arguments: lifetimeSpecifierArgumentList,
921+ rightParen: missingToken ( . rightParen) ,
925922 arena: self . arena
926923 )
927924 return . lifetimeTypeSpecifier( lifetimeSpecifier)
928925 }
929926
927+ let scoped = self . consume ( if: . keyword( . scoped) )
930928 var keepGoing : RawTokenSyntax ?
931929 var arguments : [ RawLifetimeSpecifierArgumentSyntax ] = [ ]
932930 var loopProgress = LoopProgressCondition ( )
@@ -947,18 +945,16 @@ extension Parser {
947945 } while keepGoing != nil && self . hasProgressed ( & loopProgress)
948946 let lifetimeSpecifierArgumentList = RawLifetimeSpecifierArgumentListSyntax ( elements: arguments, arena: self . arena)
949947 let ( unexpectedBeforeRightParen, rightParen) = self . expect ( . rightParen)
950- let argumentsSyntax = RawLifetimeSpecifierArgumentsSyntax (
948+ let lifetimeSpecifier = RawLifetimeTypeSpecifierSyntax (
949+ unexpectedBeforeDependsOnKeyword,
950+ dependsOnKeyword: dependsOnKeyword,
951951 leftParen: leftParen,
952+ scopedKeyword: scoped,
952953 arguments: lifetimeSpecifierArgumentList,
953954 unexpectedBeforeRightParen,
954955 rightParen: rightParen,
955956 arena: self . arena
956957 )
957- let lifetimeSpecifier = RawLifetimeTypeSpecifierSyntax (
958- specifier: specifier,
959- arguments: argumentsSyntax,
960- arena: self . arena
961- )
962958 return . lifetimeTypeSpecifier( lifetimeSpecifier)
963959 }
964960
@@ -976,20 +972,18 @@ extension Parser {
976972 specifiers: RawTypeSpecifierListSyntax ,
977973 attributes: RawAttributeListSyntax
978974 ) ? {
979- typealias SimpleOrLifetimeSpecifier =
980- EitherTokenSpecSet < SimpleTypeSpecifierSyntax . SpecifierOptions , LifetimeTypeSpecifierSyntax . SpecifierOptions >
981975 var specifiers : [ RawTypeSpecifierListSyntax . Element ] = [ ]
982- SPECIFIER_PARSING: while canHaveParameterSpecifier,
983- let ( specifierSpec, specifierHandle) = self . at ( anyIn: SimpleOrLifetimeSpecifier . self)
984- {
985- switch specifierSpec {
986- case . lhs: specifiers. append ( parseSimpleTypeSpecifier ( specifierHandle: specifierHandle) )
987- case . rhs:
976+ SPECIFIER_PARSING: while canHaveParameterSpecifier {
977+ if let ( _, specifierHandle) = self . at ( anyIn: SimpleTypeSpecifierSyntax . SpecifierOptions. self) {
978+ specifiers. append ( parseSimpleTypeSpecifier ( specifierHandle: specifierHandle) )
979+ } else if self . at ( . keyword( . dependsOn) ) {
988980 if self . experimentalFeatures. contains ( . nonescapableTypes) {
989- specifiers. append ( parseLifetimeTypeSpecifier ( specifierHandle : specifierHandle ) )
981+ specifiers. append ( parseLifetimeTypeSpecifier ( ) )
990982 } else {
991983 break SPECIFIER_PARSING
992984 }
985+ } else {
986+ break SPECIFIER_PARSING
993987 }
994988 }
995989 specifiers += misplacedSpecifiers. map {
0 commit comments