]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: fix ICE with hir dump on closure
authorPhilip Herron <herron.philip@googlemail.com>
Tue, 7 Jan 2025 18:43:32 +0000 (18:43 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 21 Mar 2025 11:56:55 +0000 (12:56 +0100)
Return type and parameter types are optional on closures.

gcc/rust/ChangeLog:

* hir/rust-hir-dump.cc (Dump::visit): add null guard

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

index 5acf53e9296f85400f6397b489c09309c2aeabdc..798179d172eeb83ee7efe8500608eed76a93dc2c 100644 (file)
@@ -1244,13 +1244,17 @@ Dump::visit (ClosureExpr &e)
          auto oa = param.get_outer_attrs ();
          do_outer_attrs (oa);
          visit_field ("pattern", param.get_pattern ());
-         visit_field ("type", param.get_type ());
+
+         if (param.has_type_given ())
+           visit_field ("type", param.get_type ());
+
          end ("ClosureParam");
        }
       end_field ("params");
     }
 
-  visit_field ("return_type", e.get_return_type ());
+  if (e.has_return_type ())
+    visit_field ("return_type", e.get_return_type ());
 
   visit_field ("expr", e.get_expr ());
   end ("ClosureExpr");