]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: dump: Handle let-else properly
authorArthur Cohen <arthur.cohen@embecosm.com>
Wed, 5 Mar 2025 15:33:31 +0000 (15:33 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 31 Mar 2025 19:07:15 +0000 (21:07 +0200)
gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Add handling for diverging else
expression.

gcc/rust/ast/rust-ast-collector.cc

index 073fa728dcf1b2a6fbda872e61c27ecf961dc840..3297407e6e828d830ddc50d729230b5d20eb5044 100644 (file)
@@ -22,6 +22,7 @@
 #include "rust-expr.h"
 #include "rust-item.h"
 #include "rust-keyword-values.h"
+#include "rust-location.h"
 #include "rust-path.h"
 #include "rust-system.h"
 #include "rust-token.h"
@@ -2587,6 +2588,13 @@ TokenCollector::visit (LetStmt &stmt)
       push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
       visit (stmt.get_init_expr ());
     }
+
+  if (stmt.has_else_expr ())
+    {
+      push (Rust::Token::make (ELSE, UNDEF_LOCATION));
+      visit (stmt.get_else_expr ());
+    }
+
   push (Rust::Token::make (SEMICOLON, UNDEF_LOCATION));
 }