Skip to content

Commit c976bc1

Browse files
committed
small polish of loan invalidations fact generation
1 parent 951901b commit c976bc1

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

compiler/rustc_borrowck/src/polonius/invalidation.rs renamed to compiler/rustc_borrowck/src/polonius/loan_invalidations.rs

+10-20
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,12 @@ pub(super) fn emit_loan_invalidations<'tcx>(
2424
) {
2525
let _prof_timer = tcx.prof.generic_activity("polonius_fact_generation");
2626
let dominators = body.basic_blocks.dominators();
27-
let mut ig = InvalidationGenerator {
28-
all_facts,
29-
borrow_set,
30-
tcx,
31-
location_table,
32-
body: body,
33-
dominators,
34-
};
35-
ig.visit_body(body);
27+
let mut visitor =
28+
LoanInvalidationsGenerator { all_facts, borrow_set, tcx, location_table, body, dominators };
29+
visitor.visit_body(body);
3630
}
3731

38-
struct InvalidationGenerator<'cx, 'tcx> {
32+
struct LoanInvalidationsGenerator<'cx, 'tcx> {
3933
tcx: TyCtxt<'tcx>,
4034
all_facts: &'cx mut AllFacts,
4135
location_table: &'cx LocationTable,
@@ -46,7 +40,7 @@ struct InvalidationGenerator<'cx, 'tcx> {
4640

4741
/// Visits the whole MIR and generates `invalidates()` facts.
4842
/// Most of the code implementing this was stolen from `borrow_check/mod.rs`.
49-
impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
43+
impl<'cx, 'tcx> Visitor<'tcx> for LoanInvalidationsGenerator<'cx, 'tcx> {
5044
fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
5145
self.check_activations(location);
5246

@@ -208,7 +202,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
208202
}
209203
}
210204

211-
impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
205+
impl<'cx, 'tcx> LoanInvalidationsGenerator<'cx, 'tcx> {
212206
/// Simulates mutation of a place.
213207
fn mutate_place(&mut self, location: Location, place: Place<'tcx>, kind: AccessDepth) {
214208
self.access_place(
@@ -342,20 +336,16 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
342336
rw: ReadOrWrite,
343337
) {
344338
debug!(
345-
"invalidation::check_access_for_conflict(location={:?}, place={:?}, sd={:?}, \
346-
rw={:?})",
339+
"check_access_for_conflict(location={:?}, place={:?}, sd={:?}, rw={:?})",
347340
location, place, sd, rw,
348341
);
349-
let tcx = self.tcx;
350-
let body = self.body;
351-
let borrow_set = self.borrow_set;
352342
each_borrow_involving_path(
353343
self,
354-
tcx,
355-
body,
344+
self.tcx,
345+
self.body,
356346
location,
357347
(sd, place),
358-
borrow_set,
348+
self.borrow_set,
359349
|_| true,
360350
|this, borrow_index, borrow| {
361351
match (rw, borrow.kind) {

compiler/rustc_borrowck/src/polonius/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::location::LocationTable;
1313
use crate::type_check::free_region_relations::UniversalRegionRelations;
1414
use crate::universal_regions::UniversalRegions;
1515

16-
mod invalidation;
16+
mod loan_invalidations;
1717
mod loan_kills;
1818

1919
/// Emit facts needed for move/init analysis: moves and assignments.
@@ -144,7 +144,7 @@ pub(crate) fn emit_loan_invalidations_facts<'tcx>(
144144
return;
145145
};
146146

147-
invalidation::emit_loan_invalidations(tcx, all_facts, location_table, body, borrow_set);
147+
loan_invalidations::emit_loan_invalidations(tcx, all_facts, location_table, body, borrow_set);
148148
}
149149

150150
/// Emit facts about CFG points and edges, as well as locations where loans are killed.

0 commit comments

Comments
 (0)