diff options
author | Philip Herron <herron.philip@googlemail.com> | 2023-08-21 12:35:26 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2023-08-23 13:23:09 +0000 |
commit | 4baf8ab8f218c2c7c6c3e04f0ee2a09a2ae1165e (patch) | |
tree | a9119bad10a3aa4dbd2e5e62d6e1201a852581a3 /gcc/rust/backend | |
parent | a6134331c80856bdcb3269bee81b2c80e728f6f8 (diff) | |
download | gcc-4baf8ab8f218c2c7c6c3e04f0ee2a09a2ae1165e.zip gcc-4baf8ab8f218c2c7c6c3e04f0ee2a09a2ae1165e.tar.gz gcc-4baf8ab8f218c2c7c6c3e04f0ee2a09a2ae1165e.tar.bz2 |
gccrs: Fix compilation of types which hold onto dangling infer vars
There is a case where some generic types are holding onto inference
variable pointers directly. So this gives the backend a chance to do one
final lookup to resolve the type.
This now allows us to compile a full test case for iterators but there is
still one miscompilation in here which results in a segv on O2 and bad
result on -O0.
Addresses #1895
gcc/rust/ChangeLog:
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): do a final lookup
gcc/testsuite/ChangeLog:
* rust/compile/iterators1.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-type.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/gcc/rust/backend/rust-compile-type.cc b/gcc/rust/backend/rust-compile-type.cc index 4e7b624..03f51a8 100644 --- a/gcc/rust/backend/rust-compile-type.cc +++ b/gcc/rust/backend/rust-compile-type.cc @@ -106,9 +106,24 @@ TyTyResolveCompile::visit (const TyTy::ErrorType &) } void -TyTyResolveCompile::visit (const TyTy::InferType &) +TyTyResolveCompile::visit (const TyTy::InferType &type) { - translated = error_mark_node; + const TyTy::BaseType *orig = &type; + TyTy::BaseType *lookup = nullptr; + bool ok = ctx->get_tyctx ()->lookup_type (type.get_ref (), &lookup); + if (!ok) + { + translated = error_mark_node; + return; + } + + if (orig == lookup) + { + translated = error_mark_node; + return; + } + + translated = TyTyResolveCompile::compile (ctx, lookup); } void |