]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Fix ICE during hir dump of deferred anon constant
authorPhilip Herron <herron.philip@googlemail.com>
Thu, 31 Jul 2025 20:17:18 +0000 (21:17 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 5 Aug 2025 14:37:01 +0000 (16:37 +0200)
gcc/rust/ChangeLog:

* hir/rust-hir-dump.cc (Dump::visit): check for expression
* hir/tree/rust-hir.cc (AnonConst::as_string): likewise

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/hir/rust-hir-dump.cc
gcc/rust/hir/tree/rust-hir.cc

index afee7b42f47f310360297452583b740adde5bf62..0a2fc818517e28caf1a70b0834c96f47e94cd05a 100644 (file)
@@ -1302,7 +1302,10 @@ Dump::visit (AnonConst &e)
   begin ("AnonConst");
   do_expr (e);
 
-  visit_field ("inner", e.get_inner_expr ());
+  if (e.is_deferred ())
+    put_field ("inner", "_");
+  else
+    visit_field ("inner", e.get_inner_expr ());
 
   end ("AnonConst");
 }
index dc94fb5b1eb7adf1f225042d8311490d7b09de62..a802e8cd0553d1065c8ba5801da559e72d513bc3 100644 (file)
@@ -1055,7 +1055,10 @@ AnonConst::as_string () const
   std::string istr = indent_spaces (enter);
   std::string str = istr + "AnonConst:\n" + istr;
 
-  str += get_inner_expr ().as_string ();
+  if (expr.has_value ())
+    str += get_inner_expr ().as_string ();
+  else
+    str += "_";
 
   str += "\n" + indent_spaces (out);