Skip to content

Commit 9cd4529

Browse files
committed
Use the detach() operation now that it's available.
It's more efficient than rebuilding the node.
1 parent f6613e3 commit 9cd4529

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

Sources/_SwiftSyntaxMacros/Syntax+MacroEvaluation.swift

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,6 @@ struct ThrownErrorDiagnostic: DiagnosticMessage {
2525
}
2626

2727
extension MacroExpansionExprSyntax {
28-
private func disconnectedCopy() -> MacroExpansionExprSyntax {
29-
MacroExpansionExprSyntax(
30-
unexpectedBeforePoundToken, poundToken: poundToken,
31-
unexpectedBetweenPoundTokenAndMacro, macro: macro,
32-
genericArguments: genericArguments,
33-
unexpectedBetweenGenericArgumentsAndLeftParen, leftParen: leftParen,
34-
unexpectedBetweenLeftParenAndArgumentList, argumentList: argumentList,
35-
unexpectedBetweenArgumentListAndRightParen, rightParen: rightParen,
36-
unexpectedBetweenRightParenAndTrailingClosure,
37-
trailingClosure: trailingClosure,
38-
unexpectedBetweenTrailingClosureAndAdditionalTrailingClosures,
39-
additionalTrailingClosures: additionalTrailingClosures,
40-
unexpectedAfterAdditionalTrailingClosures
41-
)
42-
}
43-
4428
/// Evaluate the given macro for this syntax node, producing the expanded
4529
/// result and (possibly) some diagnostics.
4630
func evaluateMacro(
@@ -53,7 +37,7 @@ extension MacroExpansionExprSyntax {
5337

5438
// Handle the rewrite.
5539
do {
56-
return try exprMacro.expansion(of: disconnectedCopy(), in: &context)
40+
return try exprMacro.expansion(of: detach(), in: &context)
5741
} catch {
5842
// Record the error
5943
context.diagnose(

0 commit comments

Comments
 (0)