about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/transform/generator.rs
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2020-10-04 11:01:38 -0700
committerDylan MacKenzie <ecstaticmorse@gmail.com>2020-10-04 11:01:38 -0700
commit6f61e71648805cb3cdf8462ca7690938c38442f4 (patch)
tree279b7903182d009a5196138ee9309f978e3c9811 /compiler/rustc_mir/src/transform/generator.rs
parent938d8fd805c682ebca4e4c3bca7bde50d120b420 (diff)
Remember the `MirSource` for each `Body`
Diffstat (limited to 'compiler/rustc_mir/src/transform/generator.rs')
-rw-r--r--compiler/rustc_mir/src/transform/generator.rs26
1 files changed, 11 insertions, 15 deletions
diff --git a/compiler/rustc_mir/src/transform/generator.rs b/compiler/rustc_mir/src/transform/generator.rs
index 1fffcf81515..7c3a0502dec 100644
--- a/compiler/rustc_mir/src/transform/generator.rs
+++ b/compiler/rustc_mir/src/transform/generator.rs
@@ -55,7 +55,7 @@ use crate::dataflow::impls::{
 use crate::dataflow::{self, Analysis};
 use crate::transform::no_landing_pads::no_landing_pads;
 use crate::transform::simplify;
-use crate::transform::{MirPass, MirSource};
+use crate::transform::MirPass;
 use crate::util::dump_mir;
 use crate::util::expand_aggregate;
 use crate::util::storage;
@@ -451,11 +451,10 @@ struct LivenessInfo {
 fn locals_live_across_suspend_points(
     tcx: TyCtxt<'tcx>,
     body: &Body<'tcx>,
-    source: MirSource<'tcx>,
     always_live_locals: &storage::AlwaysLiveLocals,
     movable: bool,
 ) -> LivenessInfo {
-    let def_id = source.def_id();
+    let def_id = body.source.def_id();
     let body_ref: &Body<'_> = &body;
 
     // Calculate when MIR locals have live storage. This gives us an upper bound of their
@@ -915,7 +914,6 @@ fn elaborate_generator_drops<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, body: &mut
 fn create_generator_drop_shim<'tcx>(
     tcx: TyCtxt<'tcx>,
     transform: &TransformVisitor<'tcx>,
-    source: MirSource<'tcx>,
     gen_ty: Ty<'tcx>,
     body: &mut Body<'tcx>,
     drop_clean: BasicBlock,
@@ -968,7 +966,7 @@ fn create_generator_drop_shim<'tcx>(
     // unrelated code from the resume part of the function
     simplify::remove_dead_blocks(&mut body);
 
-    dump_mir(tcx, None, "generator_drop", &0, source, &body, |_, _| Ok(()));
+    dump_mir(tcx, None, "generator_drop", &0, &body, |_, _| Ok(()));
 
     body
 }
@@ -1070,7 +1068,6 @@ fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
 fn create_generator_resume_function<'tcx>(
     tcx: TyCtxt<'tcx>,
     transform: TransformVisitor<'tcx>,
-    source: MirSource<'tcx>,
     body: &mut Body<'tcx>,
     can_return: bool,
 ) {
@@ -1142,7 +1139,7 @@ fn create_generator_resume_function<'tcx>(
     // unrelated code from the drop part of the function
     simplify::remove_dead_blocks(body);
 
-    dump_mir(tcx, None, "generator_resume", &0, source, body, |_, _| Ok(()));
+    dump_mir(tcx, None, "generator_resume", &0, body, |_, _| Ok(()));
 }
 
 fn insert_clean_drop(body: &mut Body<'_>) -> BasicBlock {
@@ -1239,7 +1236,7 @@ fn create_cases<'tcx>(
 }
 
 impl<'tcx> MirPass<'tcx> for StateTransform {
-    fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
+    fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
         let yield_ty = if let Some(yield_ty) = body.yield_ty {
             yield_ty
         } else {
@@ -1249,7 +1246,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
 
         assert!(body.generator_drop.is_none());
 
-        let def_id = source.def_id();
+        let def_id = body.source.def_id();
 
         // The first argument is the generator type passed by value
         let gen_ty = body.local_decls.raw[1].ty;
@@ -1307,7 +1304,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
         let always_live_locals = storage::AlwaysLiveLocals::new(&body);
 
         let liveness_info =
-            locals_live_across_suspend_points(tcx, body, source, &always_live_locals, movable);
+            locals_live_across_suspend_points(tcx, body, &always_live_locals, movable);
 
         sanitize_witness(tcx, body, def_id, interior, &upvars, &liveness_info.saved_locals);
 
@@ -1356,23 +1353,22 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
         // This is expanded to a drop ladder in `elaborate_generator_drops`.
         let drop_clean = insert_clean_drop(body);
 
-        dump_mir(tcx, None, "generator_pre-elab", &0, source, body, |_, _| Ok(()));
+        dump_mir(tcx, None, "generator_pre-elab", &0, body, |_, _| Ok(()));
 
         // Expand `drop(generator_struct)` to a drop ladder which destroys upvars.
         // If any upvars are moved out of, drop elaboration will handle upvar destruction.
         // However we need to also elaborate the code generated by `insert_clean_drop`.
         elaborate_generator_drops(tcx, def_id, body);
 
-        dump_mir(tcx, None, "generator_post-transform", &0, source, body, |_, _| Ok(()));
+        dump_mir(tcx, None, "generator_post-transform", &0, body, |_, _| Ok(()));
 
         // Create a copy of our MIR and use it to create the drop shim for the generator
-        let drop_shim =
-            create_generator_drop_shim(tcx, &transform, source, gen_ty, body, drop_clean);
+        let drop_shim = create_generator_drop_shim(tcx, &transform, gen_ty, body, drop_clean);
 
         body.generator_drop = Some(box drop_shim);
 
         // Create the Generator::resume function
-        create_generator_resume_function(tcx, transform, source, body, can_return);
+        create_generator_resume_function(tcx, transform, body, can_return);
     }
 }