Skip to content

Commit 05d3696

Browse files
committed
Avoid an extra alloca/memcpy when auto-ref'ing fat pointers
auto_ref() handles fat pointers just fine and unlike ref_fat_ptr() does so without creating an unnecessary copy of the pointer.
1 parent ef3255b commit 05d3696

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/librustc_trans/trans/expr.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
390390
// (You might think there is a more elegant way to do this than a
391391
// skip_reborrows bool, but then you remember that the borrow checker exists).
392392
if skip_reborrows == 0 && adj.autoref.is_some() {
393-
if !type_is_sized(bcx.tcx(), datum.ty) {
394-
// Arrange cleanup
395-
let lval = unpack_datum!(bcx,
396-
datum.to_lvalue_datum(bcx, "ref_fat_ptr", expr.id));
397-
datum = unpack_datum!(bcx, ref_fat_ptr(bcx, lval));
398-
} else {
399-
datum = unpack_datum!(bcx, auto_ref(bcx, datum, expr));
400-
}
393+
datum = unpack_datum!(bcx, auto_ref(bcx, datum, expr));
401394
}
402395

403396
if let Some(target) = adj.unsize {

0 commit comments

Comments
 (0)