gccrs: Fix ICE cloning trait functions without return types

Fixes Rust-GCC/gccrs#3972.

Trait functions without an explicit return type can have a null
`return_type` in `TraitFunctionDecl`. When such declarations are copied,
the copy constructor and assignment operator currently try to clone the
return type unconditionally, and this can lead to an ICE.

Handle this case by keeping `nullptr` when there is no return type to
clone. Also add a regression test for the example from Rust-GCC/gccrs#3972.

gcc/rust/ChangeLog:

	* hir/tree/rust-hir-item.cc (TraitFunctionDecl::TraitFunctionDecl):
	Handle null return types in copy constructor.
	(TraitFunctionDecl::operator=): Likewise.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3972.rs: New test.

Signed-off-by: lishin <lishin1008@gmail.com>
2 files changed