From: Philip Herron Date: Tue, 5 Nov 2024 17:35:37 +0000 (+0000) Subject: gccrs: fix ICE for placeholder which is not setup X-Git-Tag: basepoints/gcc-16~1037 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=87e4dcd782013a10de2a1cac8ff0364e5ff06bda;p=thirdparty%2Fgcc.git gccrs: fix ICE for placeholder which is not setup We can have a case where the placeholder is not configred and the can_resolve check is not detecting this case which can lead to ICE. gcc/rust/ChangeLog: * typecheck/rust-tyty.cc (PlaceholderType::can_resolve): check for empty mappings Signed-off-by: Philip Herron --- diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index 1812c618dcb..068e3902118 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -3543,7 +3543,17 @@ bool PlaceholderType::can_resolve () const { auto context = Resolver::TypeCheckContext::get (); - return context->lookup_associated_type_mapping (get_ty_ref (), nullptr); + + BaseType *lookup = nullptr; + HirId mapping; + + if (!context->lookup_associated_type_mapping (get_ty_ref (), &mapping)) + return false; + + if (!context->lookup_type (mapping, &lookup)) + return false; + + return lookup != nullptr; } BaseType *