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

[MIR] Add PointerCast for Unsize casts of fat pointers. #33734

Merged
merged 1 commit into from
May 21, 2016

Conversation

luqmana
Copy link
Member

@luqmana luqmana commented May 19, 2016

Fixes #33387.

r? @eddyb

@@ -268,6 +269,20 @@ impl Type {
}
}

pub fn fat_ptr_data_type(&self) -> Type {
Copy link
Member

Choose a reason for hiding this comment

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

This is actually type_of::in_memory_type_of.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I looked in type_ but not type_of I guess.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, type_of::in_memory_type_of isn't what I want. For &Trait it returns {T*, (vtable)} whereas I'm only trying to cast the base and thus want just T*.

Copy link
Member

Choose a reason for hiding this comment

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

You'd want to call it on the pointee type, which you can easy get, by changing the second &ty::TyRawPtr(..) pattern to &ty::TyRawPtr(mt) and using mt.ty.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, just pulled that out into type_of::fat_ptr_base_ty since I need to call it from 2 different places and the second is not already within a match giving easy access to mt.ty.

@eddyb
Copy link
Member

eddyb commented May 19, 2016

LGTM, except for using LLVM to get at information we already have.

@arielb1
Copy link
Contributor

arielb1 commented May 19, 2016

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 19, 2016

📌 Commit 94f0918 has been approved by arielb1

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 20, 2016
…=arielb1

[MIR] Add PointerCast for Unsize casts of fat pointers.

Fixes rust-lang#33387.

r? @eddyb
bors added a commit that referenced this pull request May 20, 2016
Rollup of 6 pull requests

- Successful merges: #33668, #33676, #33683, #33734, #33739, #33745
- Failed merges: #33578
@bors bors merged commit 94f0918 into rust-lang:master May 21, 2016
@luqmana luqmana deleted the 33387-mir_fat_ptr_coerce branch May 21, 2016 05:42
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.

4 participants