]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/util/liveness.rs
Changes the type `mir::Mir` into `mir::Body`
[rust.git] / src / librustc_mir / util / liveness.rs
index cbdd50cf4052af71d62f40f2bb97e77b22767836..a3317d3956be43015ffbc99766df5c963fd0beda 100644 (file)
@@ -55,10 +55,9 @@ pub struct LivenessResult {
 }
 
 /// Computes which local variables are live within the given function
-/// `mir`. The liveness mode `mode` determines what sorts of uses are
-/// considered to make a variable live (e.g., do drops count?).
+/// `mir`, including drops.
 pub fn liveness_of_locals<'tcx>(
-    mir: &Mir<'tcx>,
+    mir: &Body<'tcx>,
 ) -> LivenessResult {
     let num_live_vars = mir.local_decls.len();
 
@@ -110,7 +109,7 @@ pub enum DefUse {
     Drop,
 }
 
-pub fn categorize<'tcx>(context: PlaceContext<'tcx>) -> Option<DefUse> {
+pub fn categorize<'tcx>(context: PlaceContext) -> Option<DefUse> {
     match context {
         ///////////////////////////////////////////////////////////////////////////
         // DEFS
@@ -147,10 +146,10 @@ pub fn categorize<'tcx>(context: PlaceContext<'tcx>) -> Option<DefUse> {
         // This won't affect the results since we use this analysis for generators
         // and we only care about the result at suspension points. Borrows cannot
         // cross suspension points so this behavior is unproblematic.
-        PlaceContext::MutatingUse(MutatingUseContext::Borrow(..)) |
-        PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow(..)) |
-        PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow(..)) |
-        PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow(..)) |
+        PlaceContext::MutatingUse(MutatingUseContext::Borrow) |
+        PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow) |
+        PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow) |
+        PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow) |
 
         PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect) |
         PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) |
@@ -220,7 +219,7 @@ fn add_use(&mut self, index: Local) {
 
 impl<'tcx> Visitor<'tcx> for DefsUsesVisitor
 {
-    fn visit_local(&mut self, &local: &Local, context: PlaceContext<'tcx>, _: Location) {
+    fn visit_local(&mut self, &local: &Local, context: PlaceContext, _: Location) {
         match categorize(context) {
             Some(DefUse::Def) => self.defs_uses.add_def(local),
             Some(DefUse::Use) | Some(DefUse::Drop) => self.defs_uses.add_use(local),
@@ -247,9 +246,9 @@ fn block<'tcx>(
 
     // Visit the various parts of the basic block in reverse. If we go
     // forward, the logic in `add_def` and `add_use` would be wrong.
-    visitor.visit_terminator(BasicBlock::new(0), b.terminator(), dummy_location);
+    visitor.visit_terminator(b.terminator(), dummy_location);
     for statement in b.statements.iter().rev() {
-        visitor.visit_statement(BasicBlock::new(0), statement, dummy_location);
+        visitor.visit_statement(statement, dummy_location);
     }
 
     visitor.defs_uses
@@ -259,7 +258,7 @@ pub fn dump_mir<'a, 'tcx>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     pass_name: &str,
     source: MirSource<'tcx>,
-    mir: &Mir<'tcx>,
+    mir: &Body<'tcx>,
     result: &LivenessResult,
 ) {
     if !dump_enabled(tcx, pass_name, source) {
@@ -277,7 +276,7 @@ fn dump_matched_mir_node<'a, 'tcx>(
     pass_name: &str,
     node_path: &str,
     source: MirSource<'tcx>,
-    mir: &Mir<'tcx>,
+    mir: &Body<'tcx>,
     result: &LivenessResult,
 ) {
     let mut file_path = PathBuf::new();
@@ -298,7 +297,7 @@ fn dump_matched_mir_node<'a, 'tcx>(
 pub fn write_mir_fn<'a, 'tcx>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     src: MirSource<'tcx>,
-    mir: &Mir<'tcx>,
+    mir: &Body<'tcx>,
     w: &mut dyn Write,
     result: &LivenessResult,
 ) -> io::Result<()> {