-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Support casting boxes to dyn* #102641
Support casting boxes to dyn* #102641
Conversation
@@ -285,6 +286,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { | |||
bug!("Only valid to do a DynStar cast into a DynStar type") | |||
}; | |||
let vtable = get_vtable(bx.cx(), source.ty(self.mir, bx.tcx()), trait_ref); | |||
let data = match operand.layout.pointee_info_at(bx.cx(), Size::ZERO) { |
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.
It seems like there ought to be a better way to check if an operand is a pointer.
Also, this will likely be unnecessary once we have the conversion traits.
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.
Yeah pointee_info is definitely the wrong thing to check here. That type is for optimization hints only.
You have the full type layout here, you can just check layout.abi()
.
This comment has been minimized.
This comment has been minimized.
@rustbot author |
Huh, I'm having a hard time reproducing that failure on my machine. The tests are passing for me. |
Ah, I was able to run the tests in docker on my machine and now I'm getting the same failure. On to debugging! |
@rustbot ready |
@bors r+ |
Sure, I added a fixme comment. Feel free to r- if you think it needs more detail. |
LGTM |
Support casting boxes to dyn* Boxes have a pointer type at codegen time which LLVM does not allow to be transparently converted to an integer. Work around this by inserting a `ptrtoint` instruction if the argument is a pointer. r? `@compiler-errors` Fixes rust-lang#102427
Rollup of 7 pull requests Successful merges: - rust-lang#102641 (Support casting boxes to dyn*) - rust-lang#102836 (rustc_target: Fix json target specs using LLD linker flavors in link args) - rust-lang#102949 (should-skip-this: add missing backslash) - rust-lang#102967 (Add test for issue 102964) - rust-lang#102971 (tidy: error if a lang feature is already present) - rust-lang#102974 (Fix small word dupe typos) - rust-lang#102980 (rustdoc: merge separate `.item-info` CSS) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Boxes have a pointer type at codegen time which LLVM does not allow to be transparently converted to an integer. Work around this by inserting a
ptrtoint
instruction if the argument is a pointer.r? @compiler-errors
Fixes #102427