mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #64019 from jckarter/se-0366-consume-final-spelling
Implement `consume x` operator with the accepted SE-0366 syntax.
This commit is contained in:
@@ -406,10 +406,27 @@ ParserResult<Expr> Parser::parseExprSequenceElement(Diag<> message,
|
||||
return sub;
|
||||
}
|
||||
|
||||
if (Tok.isContextualKeyword("consume")
|
||||
&& peekToken().isAny(tok::identifier, tok::kw_self)
|
||||
&& !peekToken().isAtStartOfLine()) {
|
||||
Tok.setKind(tok::contextual_keyword);
|
||||
|
||||
SourceLoc consumeLoc = consumeToken();
|
||||
ParserResult<Expr> sub =
|
||||
parseExprSequenceElement(diag::expected_expr_after_move, isExprBasic);
|
||||
if (!sub.hasCodeCompletion() && !sub.isNull()) {
|
||||
sub = makeParserResult(new (Context) MoveExpr(consumeLoc, sub.get()));
|
||||
}
|
||||
return sub;
|
||||
}
|
||||
|
||||
if (Context.LangOpts.hasFeature(Feature::MoveOnly)) {
|
||||
if (Tok.isContextualKeyword("_move")) {
|
||||
Tok.setKind(tok::contextual_keyword);
|
||||
SourceLoc awaitLoc = consumeToken();
|
||||
diagnose(Tok, diag::move_consume_final_spelling)
|
||||
.fixItReplace(awaitLoc, "consume");
|
||||
|
||||
ParserResult<Expr> sub =
|
||||
parseExprSequenceElement(diag::expected_expr_after_move, isExprBasic);
|
||||
if (!sub.hasCodeCompletion() && !sub.isNull()) {
|
||||
|
||||
Reference in New Issue
Block a user