aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-01-06 11:02:51 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-21 12:55:45 +0100
commitb0563bb8a5279719360027e3ca0305fde730e5e0 (patch)
tree38f862657b58b43d10b34a564a80372db49a5b14 /gcc/rust/hir
parent1c13bc20ca23774567e192a47d894cad362086df (diff)
downloadgcc-b0563bb8a5279719360027e3ca0305fde730e5e0.zip
gcc-b0563bb8a5279719360027e3ca0305fde730e5e0.tar.gz
gcc-b0563bb8a5279719360027e3ca0305fde730e5e0.tar.bz2
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 <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r--gcc/rust/hir/rust-hir-dump.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc
index 2590eed..5acf53e 100644
--- a/gcc/rust/hir/rust-hir-dump.cc
+++ b/gcc/rust/hir/rust-hir-dump.cc
@@ -404,7 +404,8 @@ Dump::do_qualifiedpathtype (QualifiedPathType &e)
do_mappings (e.get_mappings ());
visit_field ("type", e.get_type ());
- visit_field ("trait", e.get_trait ());
+ if (e.has_as_clause ())
+ visit_field ("trait", e.get_trait ());
}
void
@@ -521,7 +522,8 @@ Dump::do_traitfunctiondecl (TraitFunctionDecl &e)
else
put_field ("function_params", "empty");
- visit_field ("return_type", e.get_return_type ());
+ if (e.has_return_type ())
+ visit_field ("return_type", e.get_return_type ());
if (e.has_where_clause ())
put_field ("where_clause", e.get_where_clause ().as_string ());
@@ -1295,7 +1297,8 @@ Dump::visit (BreakExpr &e)
else
put_field ("label", "none");
- visit_field ("break_expr ", e.get_expr ());
+ if (e.has_break_expr ())
+ visit_field ("break_expr ", e.get_expr ());
end ("BreakExpr");
}