aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2024-11-05 17:35:37 +0000
committerPhilip Herron <philip.herron@embecosm.com>2024-11-05 18:34:21 +0000
commitdfbd71a9ed79a121d380f5240b5a72b3175c20a4 (patch)
treeb58ebbd3f1acb30632dbd778b9d36bf071a5e3bf /gcc
parent9bcd87f48898d67d94073345f04df4b28a9d9b8e (diff)
downloadgcc-dfbd71a9ed79a121d380f5240b5a72b3175c20a4.zip
gcc-dfbd71a9ed79a121d380f5240b5a72b3175c20a4.tar.gz
gcc-dfbd71a9ed79a121d380f5240b5a72b3175c20a4.tar.bz2
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 <herron.philip@googlemail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-tyty.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc
index 1651ea6..660931f 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 *