Skip to content

Commit 4baf8ab

Browse files
committed
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 <[email protected]>
1 parent a613433 commit 4baf8ab

File tree

2 files changed

+568
-2
lines changed

2 files changed

+568
-2
lines changed

gcc/rust/backend/rust-compile-type.cc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,24 @@ TyTyResolveCompile::visit (const TyTy::ErrorType &)
106106
}
107107

108108
void
109-
TyTyResolveCompile::visit (const TyTy::InferType &)
109+
TyTyResolveCompile::visit (const TyTy::InferType &type)
110110
{
111-
translated = error_mark_node;
111+
const TyTy::BaseType *orig = &type;
112+
TyTy::BaseType *lookup = nullptr;
113+
bool ok = ctx->get_tyctx ()->lookup_type (type.get_ref (), &lookup);
114+
if (!ok)
115+
{
116+
translated = error_mark_node;
117+
return;
118+
}
119+
120+
if (orig == lookup)
121+
{
122+
translated = error_mark_node;
123+
return;
124+
}
125+
126+
translated = TyTyResolveCompile::compile (ctx, lookup);
112127
}
113128

114129
void

0 commit comments

Comments
 (0)