From bb351c7a73c38e96fbc83032e23977e2926fa43e Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Mon, 26 Jul 2021 15:16:09 +0100 Subject: Fix crash when extern function item has no return type Return types are optional in rust and extern fn items can be a ZST for the result. Addresses #421 Fixes #595 --- gcc/rust/ast/rust-ast-full-test.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/rust/ast/rust-ast-full-test.cc b/gcc/rust/ast/rust-ast-full-test.cc index dd55e1d..5d32139 100644 --- a/gcc/rust/ast/rust-ast-full-test.cc +++ b/gcc/rust/ast/rust-ast-full-test.cc @@ -3595,7 +3595,8 @@ ExternalFunctionItem::as_string () const } // add type on new line - str += "\n (return) Type: " + return_type->as_string (); + str += "\n (return) Type: " + + (has_return_type () ? return_type->as_string () : "()"); // where clause str += "\n Where clause: "; -- cgit v1.1