https://gcc.gnu.org/g:dd4f1071fae28e66f6eb342d77a7842ba835bd56

commit r17-4291-gdd4f1071fae28e66f6eb342d77a7842ba835bd56
Author: Philip Herron <[email protected]>
Date:   Sun Aug 23 18:10:34 2026 +0100

    gccrs: Fix ICE when its an optional return type
    
    Fixes Rust-GCC/gccrs#4814
    
    gcc/rust/ChangeLog:
    
            * hir/rust-hir-dump.cc (Dump::do_typepathfunction): add guard
    
    Signed-off-by: Philip Herron <[email protected]>

Diff:
---
 gcc/rust/hir/rust-hir-dump.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc
index f21522b4d486..e1c2cfa8e433 100644
--- a/gcc/rust/hir/rust-hir-dump.cc
+++ b/gcc/rust/hir/rust-hir-dump.cc
@@ -406,7 +406,8 @@ void
 Dump::do_typepathfunction (TypePathFunction &e)
 {
   visit_collection ("params", e.get_params ());
-  visit_field ("return_type", e.get_return_type ());
+  if (e.has_return_type ())
+    visit_field ("return_type", e.get_return_type ());
 }
 
 void

Reply via email to