about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-12-12 06:23:03 +0000
committerbors <bors@rust-lang.org>2023-12-12 06:23:03 +0000
commit1c15b82b8a3c6fc36cf0f20bbf33a2e316be1e80 (patch)
treea519de7ad16b91715b22ed067c64b401df787736 /compiler/rustc_mir_transform/src
parent5f5d2486022ad81e999d1135ad850c4085c65bd4 (diff)
parentdae76b772d0a4ffbb0e89b1cb88792df71bbf49d (diff)
downloadrust-1c15b82b8a3c6fc36cf0f20bbf33a2e316be1e80.tar.gz
rust-1c15b82b8a3c6fc36cf0f20bbf33a2e316be1e80.zip
Auto merge of #118857 - matthiaskrgr:rollup-t02kx2u, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #118445 (Let `reuse` look inside git submodules)
 - #118756 (use bold magenta instead of bold white for highlighting)
 - #118797 (End locals' live range before suspending coroutine)
 - #118840 (remove some redundant clones)
 - #118844 (Monomorphize args while building Instance body in StableMIR)
 - #118846 (Fix BinOp `ty()` assertion and `fn_sig()` for closures)
 - #118848 (Add myself back to review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_mir_transform/src')
-rw-r--r--compiler/rustc_mir_transform/src/coroutine.rs23
1 files changed, 15 insertions, 8 deletions
diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs
index ed8b4ef3ba4..d7dd44af7d2 100644
--- a/compiler/rustc_mir_transform/src/coroutine.rs
+++ b/compiler/rustc_mir_transform/src/coroutine.rs
@@ -527,12 +527,26 @@ impl<'tcx> MutVisitor<'tcx> for TransformVisitor<'tcx> {
                         resume_arg
                     };
 
+                let storage_liveness: GrowableBitSet<Local> =
+                    self.storage_liveness[block].clone().unwrap().into();
+
+                for i in 0..self.always_live_locals.domain_size() {
+                    let l = Local::new(i);
+                    let needs_storage_dead = storage_liveness.contains(l)
+                        && !self.remap.contains_key(&l)
+                        && !self.always_live_locals.contains(l);
+                    if needs_storage_dead {
+                        data.statements
+                            .push(Statement { source_info, kind: StatementKind::StorageDead(l) });
+                    }
+                }
+
                 self.suspension_points.push(SuspensionPoint {
                     state,
                     resume,
                     resume_arg,
                     drop,
-                    storage_liveness: self.storage_liveness[block].clone().unwrap().into(),
+                    storage_liveness,
                 });
 
                 VariantIdx::new(state)
@@ -1496,13 +1510,6 @@ fn create_cases<'tcx>(
 
                 // Create StorageLive instructions for locals with live storage
                 for i in 0..(body.local_decls.len()) {
-                    if i == 2 {
-                        // The resume argument is live on function entry. Don't insert a
-                        // `StorageLive`, or the following `Assign` will read from uninitialized
-                        // memory.
-                        continue;
-                    }
-
                     let l = Local::new(i);
                     let needs_storage_live = point.storage_liveness.contains(l)
                         && !transform.remap.contains_key(&l)