Skip to content

Commit 15dc24e

Browse files
committed
Parse: repair build after swiftlang#27132
The type deduction here will copy the returned ParsedTypeSyntax which is no longer copy constructible. Use a reference to hold the result instead which should fix the build on Windows. The returned value of the `popToken` returns a `ParsedTokenSyntax` which is no longer copy constructible. Explicitly move the value.
1 parent 8aa5cae commit 15dc24e

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

include/swift/Parse/SyntaxParsingContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ class alignas(1 << SyntaxAlignInBits) SyntaxParsingContext {
300300
return SyntaxNode(std::move(rawNode));
301301
}
302302

303-
ParsedTokenSyntax popToken();
303+
ParsedTokenSyntax &&popToken();
304304

305305
/// Create a node using the tail of the collected parts. The number of parts
306306
/// is automatically determined from \c Kind. Node: limited number of \c Kind

lib/Parse/ParseType.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ Parser::TypeASTResult Parser::parseType(Diag<> MessageID,
408408
}
409409

410410
if (Tok.is(tok::arrow)) {
411-
auto InputNode = SyntaxContext->popIf<ParsedTypeSyntax>().getValue();
411+
auto InputNode(std::move(SyntaxContext->popIf<ParsedTypeSyntax>().getValue()));
412412
// Handle type-function if we have an arrow.
413413
auto ArrowLoc = Tok.getLoc();
414414
auto Arrow = consumeTokenSyntax();
@@ -741,7 +741,7 @@ Parser::TypeResult Parser::parseTypeIdentifier() {
741741
if (Base) {
742742
SyntaxContext->addSyntax(std::move(*Base));
743743
auto T = SyntaxContext->topNode<TypeSyntax>();
744-
Junk.push_back(*SyntaxContext->popIf<ParsedTypeSyntax>());
744+
Junk.push_back(std::move(*SyntaxContext->popIf<ParsedTypeSyntax>()));
745745
ITR = dyn_cast<IdentTypeRepr>(Generator.generate(T, BaseLoc));
746746
}
747747

@@ -1164,9 +1164,10 @@ Parser::TypeResult Parser::parseTypeTupleBody() {
11641164
auto InFlight = diagnose(EqualLoc, diag::tuple_type_init);
11651165
if (Init.isNonNull())
11661166
InFlight.fixItRemove(SourceRange(EqualLoc, Init.get()->getEndLoc()));
1167-
auto Expr = *SyntaxContext->popIf<ParsedExprSyntax>();
11681167
Initializer = ParsedSyntaxRecorder::makeInitializerClause(
1169-
std::move(*Equal), std::move(Expr), *SyntaxContext);
1168+
std::move(*Equal),
1169+
std::move(*SyntaxContext->popIf<ParsedExprSyntax>()),
1170+
*SyntaxContext);
11701171
}
11711172

11721173
Comma = consumeTokenSyntaxIf(tok::comma);

lib/Parse/SyntaxParsingContext.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ const SyntaxParsingContext *SyntaxParsingContext::getRoot() const {
163163
return Curr;
164164
}
165165

166-
ParsedTokenSyntax SyntaxParsingContext::popToken() {
167-
return popIf<ParsedTokenSyntax>().getValue();
166+
ParsedTokenSyntax &&SyntaxParsingContext::popToken() {
167+
return std::move(popIf<ParsedTokenSyntax>().getValue());
168168
}
169169

170170
/// Add Token with Trivia to the parts.
@@ -334,7 +334,7 @@ SyntaxParsingContext::~SyntaxParsingContext() {
334334
Storage.push_back(std::move(BridgedNode.getValue()));
335335
}
336336
} else {
337-
auto node = bridgeAs(CtxtKind, getParts()).getValue();
337+
auto node(std::move(bridgeAs(CtxtKind, getParts()).getValue()));
338338
Storage.erase(Storage.begin() + Offset, Storage.end());
339339
Storage.emplace_back(std::move(node));
340340
}

0 commit comments

Comments
 (0)