Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gccrs: Fix compilation of types which hold onto dangling infer vars #2575

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

philberty
Copy link
Member

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.

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]>
@philberty philberty added the bug label Aug 21, 2023
@philberty philberty added this pull request to the merge queue Aug 23, 2023
Merged via the queue into master with commit 4baf8ab Aug 23, 2023
Comment on lines +503 to +504
mem::swap(&mut n, &mut self.start);
Option::Some(n)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the original code uses mem::replace to get the "old value" before updating self.start. so this should be changed to something like:

let tmp = self.start;
self.start = n;
Option::Some(tmp)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants