]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: collector: Change match arm format
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 28 Jun 2023 11:12:07 +0000 (13:12 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:49:33 +0000 (18:49 +0100)
Match arm were not readable with previous format options.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Change
formatting.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ast/rust-ast-collector.cc

index 8fc0f3dcc8df43d78d98f31fc685ceb11ae8ca81..aad948e02d8e7eaeb9ec36fe6ec714f3fd795d99 100644 (file)
@@ -1481,10 +1481,13 @@ TokenCollector::visit (MatchArm &arm)
 void
 TokenCollector::visit (MatchCase &match_case)
 {
+  indentation ();
   visit (match_case.get_arm ());
   push (Rust::Token::make (MATCH_ARROW, Location ()));
   visit (match_case.get_expr ());
+  indentation ();
   push (Rust::Token::make (COMMA, Location ()));
+  newline ();
 }
 
 void
@@ -1493,11 +1496,15 @@ TokenCollector::visit (MatchExpr &expr)
   push (Rust::Token::make (MATCH_TOK, expr.get_locus ()));
   visit (expr.get_scrutinee_expr ());
   push (Rust::Token::make (LEFT_CURLY, Location ()));
+  newline ();
+  increment_indentation ();
   visit_items_as_lines (expr.get_inner_attrs ());
   for (auto &arm : expr.get_match_cases ())
     {
       visit (arm);
     }
+  decrement_indentation ();
+  indentation ();
   push (Rust::Token::make (RIGHT_CURLY, Location ()));
 }