]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: fix ICE for placeholder which is not setup
authorPhilip Herron <herron.philip@googlemail.com>
Tue, 5 Nov 2024 17:35:37 +0000 (17:35 +0000)
committerPhilip Herron <philip.herron@embecosm.com>
Tue, 5 Nov 2024 18:34:21 +0000 (18:34 +0000)
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 <herron.philip@googlemail.com>
gcc/rust/typecheck/rust-tyty.cc

index 1651ea68591435726a610996ca463e4c94e2e179..660931f8b945d81cc1389facbda9444a4e578c3e 100644 (file)
@@ -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 *