]> git.lizzy.rs Git - rust.git/commitdiff
Use `&` to do deref coercion for `ReadOnlyBodyAndCache`
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Sat, 28 Mar 2020 21:54:41 +0000 (14:54 -0700)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Sun, 29 Mar 2020 20:30:26 +0000 (13:30 -0700)
19 files changed:
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/mod.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/const_eval/eval_queries.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/def_use.rs

index a3d68c4d53db197ec8f5f457db6b81cb744bdb21..5cbeea82512a3dbef0e834691ee68977bb03366f 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 5216326a276f1b00dbb11b31947d3cf9876bb826..919d3f2ab321c8c532fbd5f2036d6c68be96c8fd 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 8e0b4426991df49dff7e24ea1757443afe787f51..e343fba329bacb75b528ee2be9b1776053e91d9c 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 741192323fe2a8a19eee5c809ce6deec57a3765c..653578cc1562861109e80131f2611f7a3609936e 100644 (file)
@@ -37,7 +37,7 @@ pub(super) fn generate_invalidates<'tcx>(
             body: &body,
             dominators,
         };
-        ig.visit_body(*body);
+        ig.visit_body(&body);
     }
 }
 
index e3dc9e0f1050390e1c0c8a83a7ffc2e268993fa2..b6c3ae0fb876c69d2bc0686670f845f835b801d4 100644 (file)
@@ -299,8 +299,8 @@ fn do_mir_borrowck<'a, 'tcx>(
     }
 
     dataflow::visit_results(
-        &*body,
-        traversal::reverse_postorder(&*body).map(|(bb, _)| bb),
+        &body,
+        traversal::reverse_postorder(&body).map(|(bb, _)| bb),
         &results,
         &mut mbcx,
     );
index 6738bb4833788cf6e71a3270525146a96781989a..9a4eeb8ffc4983f21e644f116df8bdaa2aacc4f4 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 ddced3f355ec81e7ed466943c9ef761919e399c7..9bb1bbeaf00375d9f94366895e0376de404d8467 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 3a0b908332f23e4869d5b5d0f9131622f2befcec..b8dd1010b4c8f2fd58d270872da62533242f7ca2 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
     };
 
@@ -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 d4f54d927a74d99ce0646c8786cfddb8ca89a1ec..7fbf8842860cf0042b14a32806933a8e34384415 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 ffbff00cf376005a6b983d0ddc9c247b1ad67383..b0ef539d96b847f454981c04e832fc48487c9467 100644 (file)
@@ -307,7 +307,7 @@ pub fn const_eval_raw_provider<'tcx>(
     );
 
     let res = ecx.load_mir(cid.instance.def, cid.promoted);
-    res.and_then(|body| eval_body_using_ecx(&mut ecx, cid, *body))
+    res.and_then(|body| eval_body_using_ecx(&mut ecx, cid, &body))
         .and_then(|place| {
             Ok(RawConst { alloc_id: place.ptr.assert_ptr().alloc_id, ty: place.layout.ty })
         })
index 30aef7f69190fda26795553e5949b72160254a19..1d18279938b2521e914749b05a550d10ec9d091a 100644 (file)
@@ -83,7 +83,7 @@ pub fn new(
     ) -> Self {
         MaybeRequiresStorage {
             body,
-            borrowed_locals: RefCell::new(ResultsRefCursor::new(*body, borrowed_locals)),
+            borrowed_locals: RefCell::new(ResultsRefCursor::new(&body, borrowed_locals)),
         }
     }
 }
@@ -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 69ad8471f7b5433cde84a0aab192f1c6114731eb..e42cff0269923bcbf6113644a90886e55f902605 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 1c812bd8520c5c6e7577d1cccff5c58f091b4bb5..99c3437bf69f83ce68a32e99f2348e354190e390 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 6ddd72d7436a32b326f3a659566bf06baf97a36d..546361d62f4657df96675a320436fc2a01549c0e 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 0dc8e93d6b5588cd1e92c1011ba6cab9860e38a8..e17d1cf63d5ab4b3d0bd7cd8963a4b70827a2bb2 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 699f386c41cc57c7d5122ac030183244c4a39338..030df37827f98e321b130a9a3ba0301dd764c1e3 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 e0415e4954e6150eacecb35745883927405a95c2..bb556f40387d4c890ffa420cb86cbf75fa2dc960 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 5194fb599bc284f4f23c6b5cfb31e759b9d1d43f..55ea1e40e0865f69edbf5e4667a4e7c5c20b9009 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 44aaf401fd4ea69471c4ad5b0ac7f01732aaaeb1..059cea86a4dfe013b9b0dbed077ff37a2528bdde 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
     }