Skip to content

Commit 1aacb8f

Browse files
authored
Merge pull request #17788 from rintaro/parse-identifier-drop3
[Parse] Drop Swift3 support for '$', 'throws', and 'rethrows' as identifier
2 parents 5058ec9 + a810908 commit 1aacb8f

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

include/swift/Parse/Parser.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,7 @@ class Parser {
459459
}
460460

461461
SourceLoc consumeIdentifier(Identifier *Result = nullptr) {
462-
assert(Tok.isAny(tok::identifier, tok::kw_self, tok::kw_Self,
463-
/* for Swift3 */tok::kw_throws, tok::kw_rethrows));
462+
assert(Tok.isAny(tok::identifier, tok::kw_self, tok::kw_Self));
464463
if (Result)
465464
*Result = Context.getIdentifier(Tok.getText());
466465
return consumeToken();

lib/Parse/Lexer.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -901,13 +901,9 @@ void Lexer::lexDollarIdent() {
901901
}
902902

903903
if (CurPtr == tokStart + 1) {
904-
// It is always an error to see a standalone '$' when not in Swift 3
905-
// compatibility mode.
906-
if (!LangOpts.isSwiftVersion3()) {
907-
// Offer to replace '$' with '`$`'.
908-
diagnose(tokStart, diag::standalone_dollar_identifier)
909-
.fixItReplaceChars(getSourceLoc(tokStart), getSourceLoc(CurPtr), "`$`");
910-
}
904+
// It is an error to see a standalone '$'. Offer to replace '$' with '`$`'.
905+
diagnose(tokStart, diag::standalone_dollar_identifier)
906+
.fixItReplaceChars(getSourceLoc(tokStart), getSourceLoc(CurPtr), "`$`");
911907
return formToken(tok::identifier, tokStart);
912908
}
913909

lib/Parse/Parser.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -778,23 +778,16 @@ void Parser::StructureMarkerRAII::diagnoseOverflow() {
778778
bool Parser::parseIdentifier(Identifier &Result, SourceLoc &Loc,
779779
const Diagnostic &D) {
780780
switch (Tok.getKind()) {
781-
case tok::kw_throws:
782-
case tok::kw_rethrows:
783-
if (!Context.isSwiftVersion3())
784-
break;
785-
// Swift3 accepts 'throws' and 'rethrows'
786-
LLVM_FALLTHROUGH;
787781
case tok::kw_self:
788782
case tok::kw_Self:
789783
case tok::identifier:
790784
Loc = consumeIdentifier(&Result);
791785
return false;
792786
default:
793-
break;
787+
checkForInputIncomplete();
788+
diagnose(Tok, D);
789+
return true;
794790
}
795-
checkForInputIncomplete();
796-
diagnose(Tok, D);
797-
return true;
798791
}
799792

800793
bool Parser::parseSpecificIdentifier(StringRef expected, SourceLoc &loc,

0 commit comments

Comments
 (0)