aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2024-11-21 17:27:31 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-21 12:33:01 +0100
commit6e90ff47c658f5a5e97b4b3ae1501efb6e076303 (patch)
tree6c2ce652876f0a5f56c7858e1f0462897e538218 /gcc/rust/hir
parent066cd2e1f817bc0009fe634983abd06d1d295d89 (diff)
downloadgcc-6e90ff47c658f5a5e97b4b3ae1501efb6e076303.zip
gcc-6e90ff47c658f5a5e97b4b3ae1501efb6e076303.tar.gz
gcc-6e90ff47c658f5a5e97b4b3ae1501efb6e076303.tar.bz2
gccrs: fix crashes in hir dump since move to references
gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::visit): add guards Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r--gcc/rust/hir/rust-hir-dump.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc
index 81cb881..1b48b29 100644
--- a/gcc/rust/hir/rust-hir-dump.cc
+++ b/gcc/rust/hir/rust-hir-dump.cc
@@ -359,7 +359,8 @@ Dump::do_matcharm (MatchArm &e)
// FIXME Can't remember how to handle that. Let's see later.
// do_outer_attrs(e);
visit_collection ("match_arm_patterns", e.get_patterns ());
- visit_field ("guard_expr", e.get_guard_expr ());
+ if (e.has_match_arm_guard ())
+ visit_field ("guard_expr", e.get_guard_expr ());
end ("MatchArm");
}
@@ -1264,7 +1265,8 @@ Dump::visit (BlockExpr &e)
visit_collection ("statements", e.get_statements ());
- visit_field ("expr", e.get_final_expr ());
+ if (e.has_final_expr ())
+ visit_field ("expr", e.get_final_expr ());
end ("BlockExpr");
}
@@ -1489,7 +1491,8 @@ Dump::visit (TypeParam &e)
visit_collection ("type_param_bounds", e.get_type_param_bounds ());
- visit_field ("type", e.get_type ());
+ if (e.has_type ())
+ visit_field ("type", e.get_type ());
end ("TypeParam");
}
@@ -1655,7 +1658,8 @@ Dump::visit (Function &e)
put_field ("function_params", "empty");
}
- visit_field ("return_type", e.get_return_type ());
+ if (e.has_function_return_type ())
+ visit_field ("return_type", e.get_return_type ());
if (!e.has_where_clause ())
put_field ("where_clause", "none");