Skip to content

Commit 48aa71c

Browse files
committed
gccrs: fix ICE during HIR dump
These hir nodes have optional expressions which need guarded gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::do_qualifiedpathtype): add guard (Dump::do_traitfunctiondecl): likewise (Dump::visit): likewise Signed-off-by: Philip Herron <[email protected]>
1 parent a62630f commit 48aa71c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,8 @@ Dump::do_qualifiedpathtype (QualifiedPathType &e)
404404
do_mappings (e.get_mappings ());
405405
visit_field ("type", e.get_type ());
406406

407-
visit_field ("trait", e.get_trait ());
407+
if (e.has_as_clause ())
408+
visit_field ("trait", e.get_trait ());
408409
}
409410

410411
void
@@ -521,7 +522,8 @@ Dump::do_traitfunctiondecl (TraitFunctionDecl &e)
521522
else
522523
put_field ("function_params", "empty");
523524

524-
visit_field ("return_type", e.get_return_type ());
525+
if (e.has_return_type ())
526+
visit_field ("return_type", e.get_return_type ());
525527

526528
if (e.has_where_clause ())
527529
put_field ("where_clause", e.get_where_clause ().as_string ());
@@ -1295,7 +1297,8 @@ Dump::visit (BreakExpr &e)
12951297
else
12961298
put_field ("label", "none");
12971299

1298-
visit_field ("break_expr ", e.get_expr ());
1300+
if (e.has_break_expr ())
1301+
visit_field ("break_expr ", e.get_expr ());
12991302

13001303
end ("BreakExpr");
13011304
}

0 commit comments

Comments
 (0)