extract polonius loan invalidations fact generation
and move the polonius module to the borrowck root
This commit is contained in:
parent
459a616c4f
commit
16a5da7be2
@ -70,13 +70,13 @@ mod dataflow;
|
||||
mod def_use;
|
||||
mod diagnostics;
|
||||
mod facts;
|
||||
mod invalidation;
|
||||
mod location;
|
||||
mod member_constraints;
|
||||
mod nll;
|
||||
mod path_utils;
|
||||
mod place_ext;
|
||||
mod places_conflict;
|
||||
mod polonius;
|
||||
mod prefixes;
|
||||
mod region_infer;
|
||||
mod renumber;
|
||||
|
@ -20,16 +20,14 @@ use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
use std::str::FromStr;
|
||||
|
||||
mod polonius;
|
||||
|
||||
use crate::{
|
||||
borrow_set::BorrowSet,
|
||||
constraint_generation,
|
||||
consumers::ConsumerOptions,
|
||||
diagnostics::RegionErrors,
|
||||
facts::{AllFacts, AllFactsExt, RustcFacts},
|
||||
invalidation,
|
||||
location::LocationTable,
|
||||
polonius,
|
||||
region_infer::{values::RegionValueElements, RegionInferenceContext},
|
||||
renumber,
|
||||
type_check::{self, MirTypeckRegionConstraints, MirTypeckResults},
|
||||
@ -176,7 +174,13 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
|
||||
);
|
||||
|
||||
// Generate various additional constraints.
|
||||
invalidation::generate_invalidates(infcx.tcx, &mut all_facts, location_table, body, borrow_set);
|
||||
polonius::emit_loan_invalidations_facts(
|
||||
infcx.tcx,
|
||||
&mut all_facts,
|
||||
location_table,
|
||||
body,
|
||||
borrow_set,
|
||||
);
|
||||
|
||||
let def_id = body.source.def_id();
|
||||
|
||||
|
@ -14,31 +14,25 @@ use crate::{
|
||||
ReadOrWrite, Reservation, Shallow, Write, WriteKind,
|
||||
};
|
||||
|
||||
pub(super) fn generate_invalidates<'tcx>(
|
||||
/// Emit `loan_invalidated_at` facts.
|
||||
pub(super) fn emit_loan_invalidations<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
all_facts: &mut Option<AllFacts>,
|
||||
all_facts: &mut AllFacts,
|
||||
location_table: &LocationTable,
|
||||
body: &Body<'tcx>,
|
||||
borrow_set: &BorrowSet<'tcx>,
|
||||
) {
|
||||
if all_facts.is_none() {
|
||||
// Nothing to do if we don't have any facts
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(all_facts) = all_facts {
|
||||
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 _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);
|
||||
}
|
||||
|
||||
struct InvalidationGenerator<'cx, 'tcx> {
|
@ -4,6 +4,7 @@
|
||||
//! parity.
|
||||
|
||||
use rustc_middle::mir::{Body, LocalKind, Location, START_BLOCK};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_mir_dataflow::move_paths::{InitKind, InitLocation, MoveData};
|
||||
|
||||
use crate::borrow_set::BorrowSet;
|
||||
@ -12,6 +13,8 @@ use crate::location::LocationTable;
|
||||
use crate::type_check::free_region_relations::UniversalRegionRelations;
|
||||
use crate::universal_regions::UniversalRegions;
|
||||
|
||||
mod invalidation;
|
||||
|
||||
/// Emit facts needed for move/init analysis: moves and assignments.
|
||||
pub(crate) fn emit_move_facts(
|
||||
all_facts: &mut AllFacts,
|
||||
@ -126,3 +129,19 @@ pub(crate) fn emit_universal_region_facts(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Emit facts about loan invalidations
|
||||
pub(crate) fn emit_loan_invalidations_facts<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
all_facts: &mut Option<AllFacts>,
|
||||
location_table: &LocationTable,
|
||||
body: &Body<'tcx>,
|
||||
borrow_set: &BorrowSet<'tcx>,
|
||||
) {
|
||||
let Some(all_facts) = all_facts else {
|
||||
// Nothing to do if we don't have any facts to fill
|
||||
return;
|
||||
};
|
||||
|
||||
invalidation::emit_loan_invalidations(tcx, all_facts, location_table, body, borrow_set);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user