]> git.lizzy.rs Git - rust.git/commitdiff
Make `Visitor::visit_body` take a simple `Body`
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Thu, 26 Mar 2020 23:02:10 +0000 (16:02 -0700)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Sun, 29 Mar 2020 18:56:36 +0000 (11:56 -0700)
19 files changed:
src/librustc/mir/visit.rs
src/librustc_codegen_ssa/mir/analyze.rs
src/librustc_mir/borrow_check/borrow_set.rs
src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs
src/librustc_mir/borrow_check/invalidation.rs
src/librustc_mir/borrow_check/type_check/liveness/local_use_map.rs
src/librustc_mir/borrow_check/type_check/liveness/polonius.rs
src/librustc_mir/borrow_check/type_check/mod.rs
src/librustc_mir/borrow_check/used_muts.rs
src/librustc_mir/dataflow/impls/storage_liveness.rs
src/librustc_mir/monomorphize/collector.rs
src/librustc_mir/transform/check_consts/validation.rs
src/librustc_mir/transform/check_unsafety.rs
src/librustc_mir/transform/const_prop.rs
src/librustc_mir/transform/generator.rs
src/librustc_mir/transform/instcombine.rs
src/librustc_mir/transform/simplify.rs
src/librustc_mir/util/collect_writes.rs
src/librustc_mir/util/def_use.rs

index c1b27b40f7dcf90fc9db2092dd15ab6de9b13773..400d15cdc144be6518cc338adee383a6b64eb8f5 100644 (file)
 // variant argument) that does not require visiting, as in
 // `is_cleanup` above.
 
-macro_rules! body_cache_type {
-    (mut $a:lifetime, $tcx:lifetime) => {
+macro_rules! body_type {
+    (mut $tcx:lifetime) => {
         &mut BodyAndCache<$tcx>
     };
-    ($a:lifetime, $tcx:lifetime) => {
-        ReadOnlyBodyAndCache<$a, $tcx>
+    ($tcx:lifetime) => {
+        &Body<$tcx>
     };
 }
 
@@ -82,7 +82,7 @@ pub trait $visitor_trait_name<'tcx> {
 
             fn visit_body(
                 &mut self,
-                body: body_cache_type!($($mutability)? '_, 'tcx)
+                body: body_type!($($mutability)? 'tcx)
             ) {
                 self.super_body(body);
             }
@@ -254,7 +254,7 @@ fn visit_source_scope(&mut self,
 
             fn super_body(
                 &mut self,
-                $($mutability)? body: body_cache_type!($($mutability)? '_, 'tcx)
+                $($mutability)? body: body_type!($($mutability)? 'tcx)
             ) {
                 let span = body.span;
                 if let Some(yield_ty) = &$($mutability)? body.yield_ty {
@@ -819,7 +819,7 @@ fn super_substs(&mut self, _substs: & $($mutability)? SubstsRef<'tcx>) {
 
             fn visit_location(
                 &mut self,
-                body: body_cache_type!($($mutability)? '_, 'tcx),
+                body: body_type!($($mutability)? 'tcx),
                 location: Location
             ) {
                 let basic_block = & $($mutability)? body[location.block];
index 04680a1751734de8e296a1acb51f05b252f6517f..a3d68c4d53db197ec8f5f457db6b81cb744bdb21 100644 (file)
@@ -20,7 +20,7 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
     let mir = fx.mir;
     let mut analyzer = LocalAnalyzer::new(fx);
 
-    analyzer.visit_body(mir);
+    analyzer.visit_body(*mir);
 
     for (local, decl) in mir.local_decls.iter_enumerated() {
         let ty = fx.monomorphize(&decl.ty);
index 9f4f0ce5620b52d8149443c7368380cc10f884ec..5216326a276f1b00dbb11b31947d3cf9876bb826 100644 (file)
@@ -107,7 +107,7 @@ fn visit_local(&mut self, local: &Local, ctx: PlaceContext, _: Location) {
             LocalsStateAtExit::AllAreInvalidated
         } else {
             let mut has_storage_dead = HasStorageDead(BitSet::new_empty(body.local_decls.len()));
-            has_storage_dead.visit_body(body);
+            has_storage_dead.visit_body(*body);
             let mut has_storage_dead_or_moved = has_storage_dead.0;
             for move_out in &move_data.moves {
                 if let Some(index) = move_data.base_local(move_out.path) {
index 8f18fb4a30ed3ae5a366b16378d5257e0d3aa4ff..8e0b4426991df49dff7e24ea1757443afe787f51 100644 (file)
@@ -1561,7 +1561,7 @@ fn visit_statement(&mut self, statement: &Statement<'tcx>, _: Location) {
             }
         }
         let mut visitor = FakeReadCauseFinder { place, cause: None };
-        visitor.visit_body(self.body);
+        visitor.visit_body(*self.body);
         match visitor.cause {
             Some(FakeReadCause::ForMatchGuard) => Some("match guard"),
             Some(FakeReadCause::ForIndex) => Some("indexing expression"),
index 3d1768cf0e596fa19cda67f61a4058ee1db80f56..741192323fe2a8a19eee5c809ce6deec57a3765c 100644 (file)
@@ -37,7 +37,7 @@ pub(super) fn generate_invalidates<'tcx>(
             body: &body,
             dominators,
         };
-        ig.visit_body(body);
+        ig.visit_body(*body);
     }
 }
 
index 8155aa0ee000a05a820d54d199584b163148b868..6738bb4833788cf6e71a3270525146a96781989a 100644 (file)
@@ -81,7 +81,7 @@ impl LocalUseMap {
         live_locals.iter().for_each(|&local| locals_with_use_data[local] = true);
 
         LocalUseMapBuild { local_use_map: &mut local_use_map, elements, locals_with_use_data }
-            .visit_body(body);
+            .visit_body(*body);
 
         local_use_map
     }
index 407e0628b6eb8ba6a78a34aaf93fc433d7f2f52b..ddced3f355ec81e7ed466943c9ef761919e399c7 100644 (file)
@@ -101,7 +101,7 @@ pub(super) fn populate_access_facts(
             location_table,
             move_data,
         };
-        extractor.visit_body(body);
+        extractor.visit_body(*body);
 
         facts.var_dropped_at.extend(
             dropped_at.iter().map(|&(local, location)| (local, location_table.mid_index(location))),
index 54ca0c6a2603acea908190081dcb1c8c1b5c5c51..3a0b908332f23e4869d5b5d0f9131622f2befcec 100644 (file)
@@ -210,7 +210,7 @@ fn type_check_internal<'a, 'tcx, R>(
     );
     let errors_reported = {
         let mut verifier = TypeVerifier::new(&mut checker, *body, promoted);
-        verifier.visit_body(body);
+        verifier.visit_body(*body);
         verifier.errors_reported
     };
 
@@ -435,7 +435,7 @@ fn visit_local_decl(&mut self, local: Local, local_decl: &LocalDecl<'tcx>) {
         }
     }
 
-    fn visit_body(&mut self, body: ReadOnlyBodyAndCache<'_, 'tcx>) {
+    fn visit_body(&mut self, body: &Body<'tcx>) {
         self.sanitize_type(&"return type", body.return_ty());
         for local_decl in &body.local_decls {
             self.sanitize_type(local_decl, local_decl.ty);
@@ -563,7 +563,7 @@ fn sanitize_promoted(
 
         swap_constraints(self);
 
-        self.visit_body(promoted_body);
+        self.visit_body(*promoted_body);
 
         if !self.errors_reported {
             // if verifier failed, don't do further checks to avoid ICEs
index 5e4eebb771f21d8a6cf5e26fac8cbeed481f9e49..d4f54d927a74d99ce0646c8786cfddb8ca89a1ec 100644 (file)
@@ -32,7 +32,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
                 never_initialized_mut_locals: &mut never_initialized_mut_locals,
                 mbcx: self,
             };
-            visitor.visit_body(visitor.mbcx.body);
+            visitor.visit_body(*visitor.mbcx.body);
         }
 
         // Take the union of the existed `used_mut` set with those variables we've found were
index 67d024e62d91326aa036241ccfa401ac8e587751..30aef7f69190fda26795553e5949b72160254a19 100644 (file)
@@ -250,7 +250,7 @@ impl<'mir, 'tcx> MaybeRequiresStorage<'mir, 'tcx> {
     /// Kill locals that are fully moved and have not been borrowed.
     fn check_for_move(&self, trans: &mut impl GenKill<Local>, loc: Location) {
         let mut visitor = MoveVisitor { trans, borrowed_locals: &self.borrowed_locals };
-        visitor.visit_location(self.body, loc);
+        visitor.visit_location(*self.body, loc);
     }
 }
 
index cbd19f080eb9ef8acd6a22e5f165952d7a223027..69ad8471f7b5433cde84a0aab192f1c6114731eb 100644 (file)
@@ -1162,7 +1162,7 @@ fn collect_neighbours<'tcx>(
     debug!("collect_neighbours: {:?}", instance.def_id());
     let body = tcx.instance_mir(instance.def);
 
-    MirNeighborCollector { tcx, body: &body, output, instance }.visit_body(body);
+    MirNeighborCollector { tcx, body: &body, output, instance }.visit_body(*body);
 }
 
 fn def_id_to_string(tcx: TyCtxt<'_>, def_id: DefId) -> String {
index c315a8a65dfe6273e812d75a508cb942cf455efa..1c812bd8520c5c6e7577d1cccff5c58f091b4bb5 100644 (file)
@@ -183,7 +183,7 @@ pub fn check_body(&mut self) {
             self.check_op_spanned(ops::Loop, body.span);
         }
 
-        self.visit_body(body);
+        self.visit_body(*body);
 
         // Ensure that the end result is `Sync` in a non-thread local `static`.
         let should_check_for_sync =
index d241cc5d8a33368cdd54f81e2944671680c9d51c..6ddd72d7436a32b326f3a659566bf06baf97a36d 100644 (file)
@@ -507,7 +507,7 @@ fn unsafety_check_result(tcx: TyCtxt<'_>, def_id: DefId) -> UnsafetyCheckResult
     // mir_built ensures that body has a computed cache, so we don't (and can't) attempt to
     // recompute it here.
     let body = body.unwrap_read_only();
-    checker.visit_body(body);
+    checker.visit_body(*body);
 
     check_unused_unsafe(tcx, def_id, &checker.used_unsafe, &mut checker.inherited_blocks);
     UnsafetyCheckResult {
index 5fe8f9f3771b33a3416c33686e0ad3cac5bf481b..0dc8e93d6b5588cd1e92c1011ba6cab9860e38a8 100644 (file)
@@ -778,7 +778,7 @@ fn check(body: ReadOnlyBodyAndCache<'_, '_>) -> IndexVec<Local, ConstPropMode> {
                 trace!("local {:?} can't be const propagated because it's not a temporary", local);
             }
         }
-        cpv.visit_body(body);
+        cpv.visit_body(*body);
         cpv.can_const_prop
     }
 }
index 1945efb6bf7ccf8f9b3d78c418c8a69a494942bb..699f386c41cc57c7d5122ac030183244c4a39338 100644 (file)
@@ -469,7 +469,7 @@ fn locals_live_across_suspend_points(
     // Find the MIR locals which do not use StorageLive/StorageDead statements.
     // The storage of these locals are always live.
     let mut ignored = StorageIgnored(BitSet::new_filled(body.local_decls.len()));
-    ignored.visit_body(body);
+    ignored.visit_body(*body);
 
     // Calculate the MIR locals which have been previously
     // borrowed (even if they are still active).
index 48b4d00a2e9b6480d8fa7ebbf94c9136b6d64e6a..e0415e4954e6150eacecb35745883927405a95c2 100644 (file)
@@ -26,7 +26,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, _: MirSource<'tcx>, body: &mut BodyAndCach
         let optimizations = {
             let read_only_cache = read_only!(body);
             let mut optimization_finder = OptimizationFinder::new(body, tcx);
-            optimization_finder.visit_body(read_only_cache);
+            optimization_finder.visit_body(*read_only_cache);
             optimization_finder.optimizations
         };
 
index 4c54a46642f11e3cecd151357d03a050a3b26526..5194fb599bc284f4f23c6b5cfb31e759b9d1d43f 100644 (file)
@@ -309,7 +309,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut BodyAn
         let locals = {
             let read_only_cache = read_only!(body);
             let mut marker = DeclMarker { locals: BitSet::new_empty(body.local_decls.len()), body };
-            marker.visit_body(read_only_cache);
+            marker.visit_body(*read_only_cache);
             // Return pointer and arguments are always live
             marker.locals.insert(RETURN_PLACE);
             for arg in body.args_iter() {
index 6cd2131649673384a038c7b47b1c12fe300c9173..fc9dbd73f32e7846778e51d4a1ce489e401b6499 100644 (file)
@@ -1,7 +1,6 @@
 use rustc::mir::visit::PlaceContext;
 use rustc::mir::visit::Visitor;
-use rustc::mir::ReadOnlyBodyAndCache;
-use rustc::mir::{Local, Location};
+use rustc::mir::{Body, Local, Location};
 
 crate trait FindAssignments {
     // Finds all statements that assign directly to local (i.e., X = ...)
@@ -9,10 +8,10 @@
     fn find_assignments(&self, local: Local) -> Vec<Location>;
 }
 
-impl<'a, 'tcx> FindAssignments for ReadOnlyBodyAndCache<'a, 'tcx> {
+impl<'tcx> FindAssignments for Body<'tcx> {
     fn find_assignments(&self, local: Local) -> Vec<Location> {
         let mut visitor = FindLocalAssignmentVisitor { needle: local, locations: vec![] };
-        visitor.visit_body(*self);
+        visitor.visit_body(self);
         visitor.locations
     }
 }
index aa9ddbdbda94ff36749c1fea313982d3209d5170..44aaf401fd4ea69471c4ad5b0ac7f01732aaaeb1 100644 (file)
@@ -38,7 +38,7 @@ pub fn analyze(&mut self, body: ReadOnlyBodyAndCache<'_, '_>) {
             var_debug_info_index: 0,
             in_var_debug_info: false,
         };
-        finder.visit_body(body);
+        finder.visit_body(*body);
         self.info = finder.info
     }