aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-01-07 18:43:32 +0000
committerPhilip Herron <philip.herron@embecosm.com>2025-01-07 21:04:56 +0000
commit02601c74706bbe645ee31e2e1a2cef0f168a73e2 (patch)
tree02ca4d942ac65b20c2a2a03c580a61c372eb1fea /gcc
parente891887bf6ab7b4601f22cfa0e19f206a1d52d51 (diff)
downloadgcc-02601c74706bbe645ee31e2e1a2cef0f168a73e2.zip
gcc-02601c74706bbe645ee31e2e1a2cef0f168a73e2.tar.gz
gcc-02601c74706bbe645ee31e2e1a2cef0f168a73e2.tar.bz2
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 <herron.philip@googlemail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/hir/rust-hir-dump.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc
index 112e129..b1ada75 100644
--- a/gcc/rust/hir/rust-hir-dump.cc
+++ b/gcc/rust/hir/rust-hir-dump.cc
@@ -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");