]> git.lizzy.rs Git - rust.git/commitdiff
drop glue works with raw ptrs, it must EscapeToRaw
authorRalf Jung <post@ralfj.de>
Wed, 7 Nov 2018 11:21:28 +0000 (12:21 +0100)
committerRalf Jung <post@ralfj.de>
Wed, 7 Nov 2018 15:54:31 +0000 (16:54 +0100)
src/librustc_mir/shim.rs
src/librustc_mir/transform/generator.rs

index 76a8501fb177a89c4375e3c99fa175a8da097aaf..7705396b383a95e7cd81945d43db6775357e05b0 100644 (file)
@@ -222,6 +222,14 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     );
 
     if let Some(..) = ty {
+        let dropee_ptr = Place::Local(Local::new(1+0));
+        if tcx.sess.opts.debugging_opts.mir_emit_retag {
+            // We use raw ptr operations, better prepare the alias tracking for that
+            mir.basic_blocks_mut()[START_BLOCK].statements.insert(0, Statement {
+                source_info,
+                kind: StatementKind::EscapeToRaw(Operand::Copy(dropee_ptr.clone())),
+            })
+        }
         let patch = {
             let param_env = tcx.param_env(def_id).with_reveal_all();
             let mut elaborator = DropShimElaborator {
@@ -230,7 +238,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                 tcx,
                 param_env
             };
-            let dropee = Place::Local(Local::new(1+0)).deref();
+            let dropee = dropee_ptr.deref();
             let resume_block = elaborator.patch.resume_block();
             elaborate_drops::elaborate_drop(
                 &mut elaborator,
index 5889fabee9d6e25423db1b39348ebaeeee36bcef..a292887b17e4764d4c2fef9164ed22ddd37a6be8 100644 (file)
@@ -684,6 +684,13 @@ fn create_generator_drop_shim<'a, 'tcx>(
         is_block_tail: None,
         is_user_variable: None,
     };
+    if tcx.sess.opts.debugging_opts.mir_emit_retag {
+        // Alias tracking must know we changed the type
+        mir.basic_blocks_mut()[START_BLOCK].statements.insert(0, Statement {
+            source_info,
+            kind: StatementKind::EscapeToRaw(Operand::Copy(Place::Local(self_arg()))),
+        })
+    }
 
     no_landing_pads(tcx, &mut mir);