Refactor match parse nodes. (#6870)

Use the same node kind for the body of `case` and `default` handlers. We
don't need to distinguish these in check, so don't create extra node
kinds for them.

In order to make the nodes properly delimited, make the label (`case
...` or `default`) nodes be children of the `=>` node rather than
siblings. This allows us to use the node kind of the `=>` as the
bracketing node for the complete handler, rather than having two
different bracketing node kinds, one for each kind of label.
This commit is contained in:
Richard Smith
2026-03-10 20:04:28 +00:00
committed by GitHub
parent 9e2d0a887f
commit 99bde2acb3
20 changed files with 310 additions and 338 deletions
@@ -34,13 +34,13 @@ fn f() -> i32 {
// CHECK:STDOUT: {kind: 'InvalidParse', text: '{', has_error: yes},
// CHECK:STDOUT: {kind: 'MatchCondition', text: 'match', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'MatchStatementStart', text: '{', subtree_size: 5},
// CHECK:STDOUT: {kind: 'MatchDefaultIntroducer', text: 'default'},
// CHECK:STDOUT: {kind: 'MatchDefaultEqualGreater', text: '=>'},
// CHECK:STDOUT: {kind: 'MatchDefaultStart', text: '{', subtree_size: 3},
// CHECK:STDOUT: {kind: 'MatchDefaultIntroducer', text: 'default'},
// CHECK:STDOUT: {kind: 'MatchDefault', text: '=>', subtree_size: 2},
// CHECK:STDOUT: {kind: 'MatchHandlerStart', text: '{', subtree_size: 3},
// CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '1'},
// CHECK:STDOUT: {kind: 'ReturnStatement', text: ';', subtree_size: 3},
// CHECK:STDOUT: {kind: 'MatchDefault', text: '}', subtree_size: 7},
// CHECK:STDOUT: {kind: 'MatchHandler', text: '}', subtree_size: 7},
// CHECK:STDOUT: {kind: 'MatchStatement', text: '}', subtree_size: 13},
// CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},