1
Fork 0

Parse a pattern with no arm

This commit is contained in:
Nadrieril 2023-11-27 03:15:56 +01:00
parent caa488b96e
commit 80bdcbf50a
36 changed files with 420 additions and 279 deletions

View file

@ -631,28 +631,33 @@ impl<'a> State<'a> {
self.print_expr(e);
self.space();
}
self.word_space("=>");
match &arm.body.kind {
ast::ExprKind::Block(blk, opt_label) => {
if let Some(label) = opt_label {
self.print_ident(label.ident);
self.word_space(":");
if let Some(body) = &arm.body {
self.word_space("=>");
match &body.kind {
ast::ExprKind::Block(blk, opt_label) => {
if let Some(label) = opt_label {
self.print_ident(label.ident);
self.word_space(":");
}
// The block will close the pattern's ibox.
self.print_block_unclosed_indent(blk);
// If it is a user-provided unsafe block, print a comma after it.
if let BlockCheckMode::Unsafe(ast::UserProvided) = blk.rules {
self.word(",");
}
}
// The block will close the pattern's ibox.
self.print_block_unclosed_indent(blk);
// If it is a user-provided unsafe block, print a comma after it.
if let BlockCheckMode::Unsafe(ast::UserProvided) = blk.rules {
_ => {
self.end(); // Close the ibox for the pattern.
self.print_expr(body);
self.word(",");
}
}
_ => {
self.end(); // Close the ibox for the pattern.
self.print_expr(&arm.body);
self.word(",");
}
} else {
self.word(",");
}
self.end(); // Close enclosing cbox.
}