Skip to content

Commit

Permalink
gccrs: fix ICE with hir dump on closure
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
philberty committed Jan 7, 2025
1 parent e891887 commit 02601c7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions gcc/rust/hir/rust-hir-dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 02601c7

Please sign in to comment.