]> git.proxmox.com Git - rustc.git/blobdiff - src/librustc/mir/visit.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / librustc / mir / visit.rs
index 3f714ff4d5152b3eef0a134fc49b92232e4b0d62..ead8de86dbae4094f555d09068fde43057d6a0cf 100644 (file)
@@ -11,7 +11,7 @@
 use middle::const_val::ConstVal;
 use hir::def_id::DefId;
 use ty::subst::Substs;
-use ty::{ClosureSubsts, FnOutput, Region, Ty};
+use ty::{ClosureSubsts, Region, Ty};
 use mir::repr::*;
 use rustc_const_math::ConstUsize;
 use rustc_data_structures::tuple_slice::TupleSlice;
@@ -38,9 +38,7 @@ use syntax_pos::Span;
 //
 // For the most part, we do not destructure things external to the
 // MIR, e.g. types, spans, etc, but simply visit them and stop. This
-// avoids duplication with other visitors like `TypeFoldable`. But
-// there is one exception: we do destructure the `FnOutput` to reach
-// the type within. Just because.
+// avoids duplication with other visitors like `TypeFoldable`.
 //
 // ## Updating
 //
@@ -192,11 +190,6 @@ macro_rules! make_mir_visitor {
                 self.super_source_info(source_info);
             }
 
-            fn visit_fn_output(&mut self,
-                               fn_output: & $($mutability)* FnOutput<'tcx>) {
-                self.super_fn_output(fn_output);
-            }
-
             fn visit_ty(&mut self,
                         ty: & $($mutability)* Ty<'tcx>) {
                 self.super_ty(ty);
@@ -261,7 +254,7 @@ macro_rules! make_mir_visitor {
                     self.visit_visibility_scope_data(scope);
                 }
 
-                self.visit_fn_output(&$($mutability)* mir.return_ty);
+                self.visit_ty(&$($mutability)* mir.return_ty);
 
                 for var_decl in &$($mutability)* mir.var_decls {
                     self.visit_var_decl(var_decl);
@@ -323,6 +316,15 @@ macro_rules! make_mir_visitor {
                                           ref $($mutability)* rvalue) => {
                         self.visit_assign(block, lvalue, rvalue);
                     }
+                    StatementKind::SetDiscriminant{ ref $($mutability)* lvalue, .. } => {
+                        self.visit_lvalue(lvalue, LvalueContext::Store);
+                    }
+                    StatementKind::StorageLive(ref $($mutability)* lvalue) => {
+                        self.visit_lvalue(lvalue, LvalueContext::StorageLive);
+                    }
+                    StatementKind::StorageDead(ref $($mutability)* lvalue) => {
+                        self.visit_lvalue(lvalue, LvalueContext::StorageDead);
+                    }
                 }
             }
 
@@ -699,16 +701,6 @@ macro_rules! make_mir_visitor {
                 self.visit_visibility_scope(scope);
             }
 
-            fn super_fn_output(&mut self, fn_output: & $($mutability)* FnOutput<'tcx>) {
-                match *fn_output {
-                    FnOutput::FnConverging(ref $($mutability)* ty) => {
-                        self.visit_ty(ty);
-                    }
-                    FnOutput::FnDiverging => {
-                    }
-                }
-            }
-
             fn super_ty(&mut self, _ty: & $($mutability)* Ty<'tcx>) {
             }
 
@@ -756,4 +748,8 @@ pub enum LvalueContext {
 
     // Consumed as part of an operand
     Consume,
+
+    // Starting and ending a storage live range
+    StorageLive,
+    StorageDead,
 }