about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
diff options
context:
space:
mode:
authorRémy Rakic <remy.rakic+github@gmail.com>2023-11-23 14:19:04 +0000
committerRémy Rakic <remy.rakic+github@gmail.com>2023-11-26 12:00:32 +0000
commitc976bc114a36b773484689e702e6a4467bb51f42 (patch)
tree9ce39e00a5990658a323278bab8652124c1e633a /compiler/rustc_borrowck/src
parent951901bedc25b77d3f1959266225911d499d7003 (diff)
downloadrust-c976bc114a36b773484689e702e6a4467bb51f42.tar.gz
rust-c976bc114a36b773484689e702e6a4467bb51f42.zip
small polish of loan invalidations fact generation
Diffstat (limited to 'compiler/rustc_borrowck/src')
-rw-r--r--compiler/rustc_borrowck/src/polonius/loan_invalidations.rs (renamed from compiler/rustc_borrowck/src/polonius/invalidation.rs)30
-rw-r--r--compiler/rustc_borrowck/src/polonius/mod.rs4
2 files changed, 12 insertions, 22 deletions
diff --git a/compiler/rustc_borrowck/src/polonius/invalidation.rs b/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs
index 43119a97bee..23bf8457816 100644
--- a/compiler/rustc_borrowck/src/polonius/invalidation.rs
+++ b/compiler/rustc_borrowck/src/polonius/loan_invalidations.rs
@@ -24,18 +24,12 @@ pub(super) fn emit_loan_invalidations<'tcx>(
 ) {
     let _prof_timer = tcx.prof.generic_activity("polonius_fact_generation");
     let dominators = body.basic_blocks.dominators();
-    let mut ig = InvalidationGenerator {
-        all_facts,
-        borrow_set,
-        tcx,
-        location_table,
-        body: body,
-        dominators,
-    };
-    ig.visit_body(body);
+    let mut visitor =
+        LoanInvalidationsGenerator { all_facts, borrow_set, tcx, location_table, body, dominators };
+    visitor.visit_body(body);
 }
 
-struct InvalidationGenerator<'cx, 'tcx> {
+struct LoanInvalidationsGenerator<'cx, 'tcx> {
     tcx: TyCtxt<'tcx>,
     all_facts: &'cx mut AllFacts,
     location_table: &'cx LocationTable,
@@ -46,7 +40,7 @@ struct InvalidationGenerator<'cx, 'tcx> {
 
 /// Visits the whole MIR and generates `invalidates()` facts.
 /// Most of the code implementing this was stolen from `borrow_check/mod.rs`.
-impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
+impl<'cx, 'tcx> Visitor<'tcx> for LoanInvalidationsGenerator<'cx, 'tcx> {
     fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
         self.check_activations(location);
 
@@ -208,7 +202,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
     }
 }
 
-impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
+impl<'cx, 'tcx> LoanInvalidationsGenerator<'cx, 'tcx> {
     /// Simulates mutation of a place.
     fn mutate_place(&mut self, location: Location, place: Place<'tcx>, kind: AccessDepth) {
         self.access_place(
@@ -342,20 +336,16 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
         rw: ReadOrWrite,
     ) {
         debug!(
-            "invalidation::check_access_for_conflict(location={:?}, place={:?}, sd={:?}, \
-             rw={:?})",
+            "check_access_for_conflict(location={:?}, place={:?}, sd={:?}, rw={:?})",
             location, place, sd, rw,
         );
-        let tcx = self.tcx;
-        let body = self.body;
-        let borrow_set = self.borrow_set;
         each_borrow_involving_path(
             self,
-            tcx,
-            body,
+            self.tcx,
+            self.body,
             location,
             (sd, place),
-            borrow_set,
+            self.borrow_set,
             |_| true,
             |this, borrow_index, borrow| {
                 match (rw, borrow.kind) {
diff --git a/compiler/rustc_borrowck/src/polonius/mod.rs b/compiler/rustc_borrowck/src/polonius/mod.rs
index c3fdc6c7b96..9454118d9c4 100644
--- a/compiler/rustc_borrowck/src/polonius/mod.rs
+++ b/compiler/rustc_borrowck/src/polonius/mod.rs
@@ -13,7 +13,7 @@ use crate::location::LocationTable;
 use crate::type_check::free_region_relations::UniversalRegionRelations;
 use crate::universal_regions::UniversalRegions;
 
-mod invalidation;
+mod loan_invalidations;
 mod loan_kills;
 
 /// Emit facts needed for move/init analysis: moves and assignments.
@@ -144,7 +144,7 @@ pub(crate) fn emit_loan_invalidations_facts<'tcx>(
         return;
     };
 
-    invalidation::emit_loan_invalidations(tcx, all_facts, location_table, body, borrow_set);
+    loan_invalidations::emit_loan_invalidations(tcx, all_facts, location_table, body, borrow_set);
 }
 
 /// Emit facts about CFG points and edges, as well as locations where loans are killed.