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,16 +34,17 @@ fn f() -> i32 {
// CHECK:STDOUT: {kind: 'IntLiteral', text: '3'},
// CHECK:STDOUT: {kind: 'MatchCondition', text: ')', subtree_size: 3},
// CHECK:STDOUT: {kind: 'MatchStatementStart', text: '{', subtree_size: 5},
// CHECK:STDOUT: {kind: 'MatchCaseIntroducer', text: 'case'},
// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeSignature', text: '=>', has_error: yes},
// CHECK:STDOUT: {kind: 'InvalidParse', text: '=>', has_error: yes},
// CHECK:STDOUT: {kind: 'LetBindingPattern', text: '=>', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'MatchCaseStart', text: '=>', has_error: yes, subtree_size: 5},
// CHECK:STDOUT: {kind: 'MatchCase', text: '=>', has_error: yes, subtree_size: 6},
// CHECK:STDOUT: {kind: 'MatchStatement', text: '}', subtree_size: 12},
// CHECK:STDOUT: {kind: 'MatchCaseIntroducer', text: 'case'},
// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeSignature', text: '=>', has_error: yes},
// CHECK:STDOUT: {kind: 'InvalidParse', text: '=>', has_error: yes},
// CHECK:STDOUT: {kind: 'LetBindingPattern', text: '=>', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'MatchCase', text: '=>', has_error: yes, subtree_size: 5},
// CHECK:STDOUT: {kind: 'MatchHandlerStart', text: '=>', has_error: yes, subtree_size: 6},
// CHECK:STDOUT: {kind: 'MatchHandler', text: '=>', has_error: yes, subtree_size: 7},
// CHECK:STDOUT: {kind: 'MatchStatement', text: '}', subtree_size: 13},
// CHECK:STDOUT: {kind: 'ReturnStatementStart', text: 'return'},
// CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},
// CHECK:STDOUT: {kind: 'ReturnStatement', text: ';', subtree_size: 3},
// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 23},
// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 24},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]