Skip to content

Add missing cast for retslots in case of "subtyping" due to trait bounds #22667

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

Merged
merged 1 commit into from
Feb 23, 2015

Conversation

dotdash
Copy link
Contributor

@dotdash dotdash commented Feb 22, 2015

We already do this for the function arguments, but miss it for the
retslot pointer, which can lead to LLVM assertions because the retslot
has the wrong type.

Fixes #22663

We already do this for the function arguments, but miss it for the
retslot pointer, which can lead to LLVM assertions because the retslot
has the wrong type.

Fixes rust-lang#22663
@rust-highfive
Copy link
Contributor

r? @huonw

(rust_highfive has picked a reviewer for you, use r? to override)

let llformal_ret_ty = type_of::type_of(ccx, ret_ty).ptr_to();
let llret_ty = common::val_ty(llretslot);
if llformal_ret_ty != llret_ty {
// this could happen due to e.g. subtyping
Copy link
Member

Choose a reason for hiding this comment

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

Should we bother to have an assertion about what the relationship is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What kind of assertion do you have in mind? We just have the LLVM type of the retslot here (can you lookup the original Ty from that?), I don't think we can do much with that, can we?

Ultimately, we should probably ignore the trait bounds when creating the LLVM types, but this seemed like the obvious quick fix because trans_arg_datum already does the same.

And once LLVM drops typed pointers, this is all moot anyway.

Copy link
Member

Choose a reason for hiding this comment

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

I was hoping we had access to both of the Rust types, but if not, I guess we can't do anything, as you say.

@huonw
Copy link
Member

huonw commented Feb 22, 2015

@bors r+ b593

Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 23, 2015
 We already do this for the function arguments, but miss it for the
retslot pointer, which can lead to LLVM assertions because the retslot
has the wrong type.

Fixes rust-lang#22663
@alexcrichton alexcrichton merged commit b593c60 into rust-lang:master Feb 23, 2015
@dotdash dotdash deleted the retslot_cast.rs branch March 1, 2015 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Calling a function with a bad signature!"' failed.
4 participants