-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Conversation
@@ -268,6 +269,20 @@ impl Type { | |||
} | |||
} | |||
|
|||
pub fn fat_ptr_data_type(&self) -> Type { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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*
.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
.
LGTM, except for using LLVM to get at information we already have. |
9b49c4c
to
94f0918
Compare
@bors r+ rollup |
📌 Commit 94f0918 has been approved by |
…=arielb1 [MIR] Add PointerCast for Unsize casts of fat pointers. Fixes rust-lang#33387. r? @eddyb
Fixes #33387.
r? @eddyb