Skip to content

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

Merged
bors merged 1 commit into
rust-lang:masterfrom
luqmana:33387-mir_fat_ptr_coerce
May 21, 2016
Merged

[MIR] Add PointerCast for Unsize casts of fat pointers.#33734
bors merged 1 commit into
rust-lang:masterfrom
luqmana:33387-mir_fat_ptr_coerce

Conversation

@luqmana

Copy link
Copy Markdown
Contributor

Fixes#33387.

r? @eddyb

Comment threadsrc/librustc_trans/type_.rs Outdated

Copy link
Copy Markdown
Contributor

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
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

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
Copy Markdown
Contributor

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
Copy Markdown
ContributorAuthor

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
Copy Markdown
Contributor

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

@luqmana
luqmanaforce-pushed the 33387-mir_fat_ptr_coerce branch from 9b49c4c to 94f0918CompareMay 19, 2016 06:47
@arielb1

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@bors

bors commented May 19, 2016

Copy link
Copy Markdown
Collaborator

📌 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.
Fixesrust-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:masterMay 21, 2016
@luqmana
luqmana deleted the 33387-mir_fat_ptr_coerce branch May 21, 2016 05:42
Sign up for freeto 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

@luqmana@eddyb@arielb1@bors