Skip to content

Commit e25427a

Browse files
committed
During my own review, I convinced myself this was indeed a bug.
Testing indicates bug would have been caught, albeit later than one might hope, during `sync::mpsc::tests::smoke_shared_port_gone2` test.
1 parent dce1c61 commit e25427a

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/librustc_trans/trans/expr.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,22 +1004,22 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
10041004
debuginfo::set_source_location(bcx.fcx, expr.id, expr.span);
10051005
let src_datum = unpack_datum!(
10061006
bcx, src_datum.to_rvalue_datum(bcx, "ExprAssign"));
1007-
if let Some(hint_datum) = dst_datum.kind.drop_flag_info.hint_datum(bcx) {
1008-
let hint_val = hint_datum.to_value();
1009-
// XXX the checkpointed branch only does the
1010-
// drop_ty call within this branch (and I claim
1011-
// that seems like a bug). At this point I have
1012-
// moved it into the branch solely to see if it
1013-
// makes my plague of bugs go away.
1014-
bcx = glue::drop_ty_core(bcx,
1015-
dst_datum.val,
1016-
dst_datum.ty,
1017-
expr.debug_loc(),
1018-
false,
1019-
Some(hint_val));
1020-
// We are initializing or overwriting the
1021-
// destination, so we need to write "drop needed"
1022-
// into the hint.
1007+
let opt_hint_datum = dst_datum.kind.drop_flag_info.hint_datum(bcx);
1008+
let opt_hint_val = opt_hint_datum.map(|d|d.to_value());
1009+
1010+
// 1. Drop the data at the destination, passing the
1011+
// drop-hint in case the lvalue has already been
1012+
// dropped or moved.
1013+
bcx = glue::drop_ty_core(bcx,
1014+
dst_datum.val,
1015+
dst_datum.ty,
1016+
expr.debug_loc(),
1017+
false,
1018+
opt_hint_val);
1019+
1020+
// 2. We are overwriting the destination; ensure that
1021+
// its drop-hint (if any) says "initialized."
1022+
if let Some(hint_val) = opt_hint_val {
10231023
let hint_llval = hint_val.value();
10241024
let drop_needed = C_u8(bcx.fcx.ccx, adt::DTOR_NEEDED_HINT as usize);
10251025
Store(bcx, drop_needed, hint_llval);

0 commit comments

Comments
 (0)