Skip to content

Commit 9e3f571

Browse files
committed
drop glue works with raw ptrs, it must EscapeToRaw
1 parent 154835e commit 9e3f571

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/librustc_mir/shim.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,14 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
222222
);
223223

224224
if let Some(..) = ty {
225+
let dropee_ptr = Place::Local(Local::new(1+0));
226+
if tcx.sess.opts.debugging_opts.mir_emit_retag {
227+
// We use raw ptr operations, better prepare the alias tracking for that
228+
mir.basic_blocks_mut()[START_BLOCK].statements.insert(0, Statement {
229+
source_info,
230+
kind: StatementKind::EscapeToRaw(Operand::Copy(dropee_ptr.clone())),
231+
})
232+
}
225233
let patch = {
226234
let param_env = tcx.param_env(def_id).with_reveal_all();
227235
let mut elaborator = DropShimElaborator {
@@ -230,7 +238,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
230238
tcx,
231239
param_env
232240
};
233-
let dropee = Place::Local(Local::new(1+0)).deref();
241+
let dropee = dropee_ptr.deref();
234242
let resume_block = elaborator.patch.resume_block();
235243
elaborate_drops::elaborate_drop(
236244
&mut elaborator,

src/librustc_mir/transform/generator.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,13 @@ fn create_generator_drop_shim<'a, 'tcx>(
684684
is_block_tail: None,
685685
is_user_variable: None,
686686
};
687+
if tcx.sess.opts.debugging_opts.mir_emit_retag {
688+
// Alias tracking must know we changed the type
689+
mir.basic_blocks_mut()[START_BLOCK].statements.insert(0, Statement {
690+
source_info,
691+
kind: StatementKind::EscapeToRaw(Operand::Copy(Place::Local(self_arg()))),
692+
})
693+
}
687694

688695
no_landing_pads(tcx, &mut mir);
689696

0 commit comments

Comments
 (0)