@@ -131,9 +131,9 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
131131 vec ! [
132132 // ---- Top-level ----
133133 // These rules translate the swift-syntax AST (camelCase kind names),
134- // produced by the sibling `adapter` module from the ` swift-syntax-parse`
135- // binary's JSON. Anything unmatched falls through to the
136- // `unsupported_node` fallback at the end .
134+ // produced by the sibling `adapter` module from swift-syntax JSON.
135+ // Known kinds without dedicated rules become `unsupported_node`;
136+ // genuinely unknown kinds become `unhandled_node` .
137137 //
138138 // `sourceFile` holds its top-level statements in an (elided)
139139 // `statements` collection; each element is a `codeBlockItem` wrapping
@@ -1414,18 +1414,58 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
14141414 name_node: ( identifier #{ name} )
14151415 bound: { bound} )
14161416 ) ,
1417- // ---- Fallbacks ----
1418- // Bare `_` (rather than `(_)`) so this matches both named nodes
1419- // and unnamed tokens. Any unnamed token that escapes the
1420- // input-schema-specific rules (e.g. captured operators in
1421- // `additive_expression op: @op`) has its auto-translated value
1422- // replaced with an `unsupported_node` whose source range is
1423- // inherited from the original token, so `#{op}` still reads the
1424- // original text.
1425- rule!(
1426- _
1427- =>
1428- ( unsupported_node)
1417+ // ---- Explicitly unsupported roots ----
1418+ // These kinds can reach translation independently, but we do not
1419+ // currently map them to the unified AST. Syntax nested inside one of
1420+ // these roots is discarded with its parent and needs no separate rule.
1421+ rule!( ( actorDecl) => ( unsupported_node) ) ,
1422+ rule!( ( attributedType) => ( unsupported_node) ) ,
1423+ rule!( ( borrowExpr) => ( unsupported_node) ) ,
1424+ rule!( ( classRestrictionType) => ( unsupported_node) ) ,
1425+ rule!( ( compositionType) => ( unsupported_node) ) ,
1426+ rule!( ( consumeExpr) => ( unsupported_node) ) ,
1427+ rule!( ( copyExpr) => ( unsupported_node) ) ,
1428+ rule!( ( deferStmt) => ( unsupported_node) ) ,
1429+ rule!( ( discardStmt) => ( unsupported_node) ) ,
1430+ rule!( ( fallThroughStmt) => ( unsupported_node) ) ,
1431+ rule!( ( ifConfigDecl) => ( unsupported_node) ) ,
1432+ rule!( ( implicitlyUnwrappedOptionalType) => ( unsupported_node) ) ,
1433+ rule!( ( inOutExpr) => ( unsupported_node) ) ,
1434+ rule!( ( inlineArrayType) => ( unsupported_node) ) ,
1435+ rule!( ( keyPathExpr) => ( unsupported_node) ) ,
1436+ rule!( ( macroDecl) => ( unsupported_node) ) ,
1437+ rule!( ( metatypeType) => ( unsupported_node) ) ,
1438+ rule!( ( namedOpaqueReturnType) => ( unsupported_node) ) ,
1439+ rule!( ( operatorDecl) => ( unsupported_node) ) ,
1440+ rule!( ( packElementExpr) => ( unsupported_node) ) ,
1441+ rule!( ( packElementType) => ( unsupported_node) ) ,
1442+ rule!( ( packExpansionExpr) => ( unsupported_node) ) ,
1443+ rule!( ( packExpansionType) => ( unsupported_node) ) ,
1444+ rule!( ( postfixIfConfigExpr) => ( unsupported_node) ) ,
1445+ rule!( ( postfixOperatorExpr) => ( unsupported_node) ) ,
1446+ rule!( ( poundSourceLocation) => ( unsupported_node) ) ,
1447+ rule!( ( precedenceGroupDecl) => ( unsupported_node) ) ,
1448+ rule!( ( someOrAnyType) => ( unsupported_node) ) ,
1449+ rule!( ( subscriptDecl) => ( unsupported_node) ) ,
1450+ rule!( ( suppressedType) => ( unsupported_node) ) ,
1451+ rule!( ( typeExpr) => ( unsupported_node) ) ,
1452+ rule!( ( unsafeExpr) => ( unsupported_node) ) ,
1453+ rule!( ( yieldStmt) => ( unsupported_node) ) ,
1454+ // Anything reaching this final generic handler has neither a
1455+ // dedicated rule nor an explicit unsupported entry.
1456+ rule!(
1457+ _ @@node
1458+ =>
1459+ unhandled_node {
1460+ let input = ctx. ast. get_node( node) . expect( "matched node must exist" ) ;
1461+ tracing:: error!(
1462+ target: "unified_extractor" ,
1463+ node_kind = input. kind_name( ) ,
1464+ source_range = ?input. source_range( ) ,
1465+ "Unhandled Swift syntax node reached translation"
1466+ ) ;
1467+ tree!( ( unhandled_node) )
1468+ }
14291469 ) ,
14301470 ]
14311471}
0 commit comments