Skip to content

Commit 02601c7

Browse files
committed
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 <[email protected]>
1 parent e891887 commit 02601c7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

gcc/rust/hir/rust-hir-dump.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -1244,13 +1244,17 @@ Dump::visit (ClosureExpr &e)
12441244
auto oa = param.get_outer_attrs ();
12451245
do_outer_attrs (oa);
12461246
visit_field ("pattern", param.get_pattern ());
1247-
visit_field ("type", param.get_type ());
1247+
1248+
if (param.has_type_given ())
1249+
visit_field ("type", param.get_type ());
1250+
12481251
end ("ClosureParam");
12491252
}
12501253
end_field ("params");
12511254
}
12521255

1253-
visit_field ("return_type", e.get_return_type ());
1256+
if (e.has_return_type ())
1257+
visit_field ("return_type", e.get_return_type ());
12541258

12551259
visit_field ("expr", e.get_expr ());
12561260
end ("ClosureExpr");

0 commit comments

Comments
 (0)