From: Philip Herron Date: Tue, 7 Jan 2025 18:43:32 +0000 (+0000) Subject: gccrs: fix ICE with hir dump on closure X-Git-Tag: basepoints/gcc-16~955 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d3efd2a91f54a19c3c2d59d690c447c0def26367;p=thirdparty%2Fgcc.git gccrs: fix ICE with hir dump on closure 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 --- diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc index 5acf53e9296..798179d172e 100644 --- a/gcc/rust/hir/rust-hir-dump.cc +++ b/gcc/rust/hir/rust-hir-dump.cc @@ -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");