https://gcc.gnu.org/g:98e07649f16a314bcbf9d6c7a3e3fe64a236b9a8
commit r17-4320-g98e07649f16a314bcbf9d6c7a3e3fe64a236b9a8 Author: Philip Herron <[email protected]> Date: Mon Aug 31 22:24:53 2026 +0100 gccrs: make fn trait return optional This is just a basic patch to get past a crash in libcore we probably need to default to unit-type somewhere later on. gcc/rust/ChangeLog: * typecheck/rust-tyty-bounds.cc: handle assertion Signed-off-by: Philip Herron <[email protected]> Diff: --- gcc/rust/typecheck/rust-tyty-bounds.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gcc/rust/typecheck/rust-tyty-bounds.cc b/gcc/rust/typecheck/rust-tyty-bounds.cc index f72ee57f93a5..fca42d61ad31 100644 --- a/gcc/rust/typecheck/rust-tyty-bounds.cc +++ b/gcc/rust/typecheck/rust-tyty-bounds.cc @@ -332,11 +332,6 @@ TypeCheckBase::get_predicate_from_bound ( std::make_unique<HIR::TupleType> (mapping, std::move (params_copy), final_seg.get_locus ())); - // resolve the fn_once_output type which assumes there must be an output - // set - rust_assert (fn.has_return_type ()); - TypeCheckType::Resolve (fn.get_return_type ()); - HIR::TraitItem *trait_item = mappings .lookup_trait_item_lang_item (LangItem::Kind::FN_ONCE_OUTPUT, @@ -344,10 +339,16 @@ TypeCheckBase::get_predicate_from_bound ( .value (); std::vector<HIR::GenericArgsBinding> bindings; - location_t output_locus = fn.get_return_type ().get_locus (); - bindings.emplace_back (Identifier (trait_item->trait_identifier ()), - fn.get_return_type ().clone_type (), - output_locus); + + if (fn.has_return_type ()) + { + TypeCheckType::Resolve (fn.get_return_type ()); + + location_t output_locus = fn.get_return_type ().get_locus (); + bindings.emplace_back (Identifier (trait_item->trait_identifier ()), + fn.get_return_type ().clone_type (), + output_locus); + } args = HIR::GenericArgs ({} /* lifetimes */, std::move (inputs) /* type_args*/,
