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 def_use;
|
||||||
mod diagnostics;
|
mod diagnostics;
|
||||||
mod facts;
|
mod facts;
|
||||||
mod invalidation;
|
|
||||||
mod location;
|
mod location;
|
||||||
mod member_constraints;
|
mod member_constraints;
|
||||||
mod nll;
|
mod nll;
|
||||||
mod path_utils;
|
mod path_utils;
|
||||||
mod place_ext;
|
mod place_ext;
|
||||||
mod places_conflict;
|
mod places_conflict;
|
||||||
|
mod polonius;
|
||||||
mod prefixes;
|
mod prefixes;
|
||||||
mod region_infer;
|
mod region_infer;
|
||||||
mod renumber;
|
mod renumber;
|
||||||
|
@ -20,16 +20,14 @@ use std::path::PathBuf;
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
mod polonius;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
borrow_set::BorrowSet,
|
borrow_set::BorrowSet,
|
||||||
constraint_generation,
|
constraint_generation,
|
||||||
consumers::ConsumerOptions,
|
consumers::ConsumerOptions,
|
||||||
diagnostics::RegionErrors,
|
diagnostics::RegionErrors,
|
||||||
facts::{AllFacts, AllFactsExt, RustcFacts},
|
facts::{AllFacts, AllFactsExt, RustcFacts},
|
||||||
invalidation,
|
|
||||||
location::LocationTable,
|
location::LocationTable,
|
||||||
|
polonius,
|
||||||
region_infer::{values::RegionValueElements, RegionInferenceContext},
|
region_infer::{values::RegionValueElements, RegionInferenceContext},
|
||||||
renumber,
|
renumber,
|
||||||
type_check::{self, MirTypeckRegionConstraints, MirTypeckResults},
|
type_check::{self, MirTypeckRegionConstraints, MirTypeckResults},
|
||||||
@ -176,7 +174,13 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Generate various additional constraints.
|
// 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();
|
let def_id = body.source.def_id();
|
||||||
|
|
||||||
|
@ -14,19 +14,14 @@ use crate::{
|
|||||||
ReadOrWrite, Reservation, Shallow, Write, WriteKind,
|
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>,
|
tcx: TyCtxt<'tcx>,
|
||||||
all_facts: &mut Option<AllFacts>,
|
all_facts: &mut AllFacts,
|
||||||
location_table: &LocationTable,
|
location_table: &LocationTable,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
borrow_set: &BorrowSet<'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 _prof_timer = tcx.prof.generic_activity("polonius_fact_generation");
|
||||||
let dominators = body.basic_blocks.dominators();
|
let dominators = body.basic_blocks.dominators();
|
||||||
let mut ig = InvalidationGenerator {
|
let mut ig = InvalidationGenerator {
|
||||||
@ -39,7 +34,6 @@ pub(super) fn generate_invalidates<'tcx>(
|
|||||||
};
|
};
|
||||||
ig.visit_body(body);
|
ig.visit_body(body);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
struct InvalidationGenerator<'cx, 'tcx> {
|
struct InvalidationGenerator<'cx, 'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
@ -4,6 +4,7 @@
|
|||||||
//! parity.
|
//! parity.
|
||||||
|
|
||||||
use rustc_middle::mir::{Body, LocalKind, Location, START_BLOCK};
|
use rustc_middle::mir::{Body, LocalKind, Location, START_BLOCK};
|
||||||
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_mir_dataflow::move_paths::{InitKind, InitLocation, MoveData};
|
use rustc_mir_dataflow::move_paths::{InitKind, InitLocation, MoveData};
|
||||||
|
|
||||||
use crate::borrow_set::BorrowSet;
|
use crate::borrow_set::BorrowSet;
|
||||||
@ -12,6 +13,8 @@ use crate::location::LocationTable;
|
|||||||
use crate::type_check::free_region_relations::UniversalRegionRelations;
|
use crate::type_check::free_region_relations::UniversalRegionRelations;
|
||||||
use crate::universal_regions::UniversalRegions;
|
use crate::universal_regions::UniversalRegions;
|
||||||
|
|
||||||
|
mod invalidation;
|
||||||
|
|
||||||
/// Emit facts needed for move/init analysis: moves and assignments.
|
/// Emit facts needed for move/init analysis: moves and assignments.
|
||||||
pub(crate) fn emit_move_facts(
|
pub(crate) fn emit_move_facts(
|
||||||
all_facts: &mut AllFacts,
|
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