-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Avoid unnecessary temporaries when ref'ing a DST value #28787
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
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
r? @eddyb |
@@ -1709,8 +1699,11 @@ fn trans_addr_of<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, | |||
let mut bcx = bcx; | |||
let sub_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, subexpr, "addr_of")); | |||
if !type_is_sized(bcx.tcx(), sub_datum.ty) { | |||
// DST lvalue, close to a fat pointer | |||
ref_fat_ptr(bcx, sub_datum) | |||
let dest_ty = bcx.tcx().mk_imm_ref(bcx.tcx().mk_region(ty::ReStatic), sub_datum.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.
expr_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.
Thanks, fixed!
A DST value and a fat pointer to it have the same representation, all we have to do is to adjust the type of the datum holding the pointer.
6ae43a0
to
bda083f
Compare
@bors r+ |
📌 Commit bda083f has been approved by |
A DST value and a fat pointer to it have the same representation, all we have to do is to adjust the type of the datum holding the pointer.
Codegen improvements. Any numbers? |
Pretty negligible as far as optimized builds are concerned AFAICT. Didn't
|
A DST value and a fat pointer to it have the same representation, all we
have to do is to adjust the type of the datum holding the pointer.