Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasAlaif committed Oct 11, 2023
1 parent 9e79e87 commit 050bdb2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use prusti_rustc_interface::{
borrow_set::BorrowData,
consumers::{BorrowIndex, Borrows, OutlivesConstraint, PoloniusInput, RustcFacts},
},
data_structures::fx::FxHashMap,
data_structures::fx::{FxHashMap, FxHashSet},
dataflow::{Analysis, ResultsCursor},
index::IndexVec,
middle::{
Expand All @@ -30,7 +30,6 @@ pub struct OutlivesInfo<'tcx> {
pub local_constraints: Vec<OutlivesConstraint<'tcx>>, // but with no location info
pub type_ascription_constraints: Vec<OutlivesConstraint<'tcx>>,
pub location_constraints: FxHashMap<Location, Vec<OutlivesConstraint<'tcx>>>,

pub universal_constraints: Vec<(RegionVid, RegionVid)>,
}

Expand All @@ -40,7 +39,8 @@ impl<'tcx> OutlivesInfo<'tcx> {
facts2: &BorrowckFacts2<'tcx>,
ri: &RegionInfo<'tcx>,
) -> Self {
let universal_constraints = input_facts.known_placeholder_subset.clone();
let mut universal_constraints =
FxHashSet::from_iter(input_facts.known_placeholder_subset.iter().copied());

let mut universal_local_constraints = Vec::new();
let mut local_constraints = Vec::new();
Expand All @@ -57,7 +57,8 @@ impl<'tcx> OutlivesInfo<'tcx> {
if ri.map.is_universal(constraint.sup) && ri.map.is_universal(constraint.sub) {
// Not sure why the `region_inference_context` can rarely contain inter-universal constraints,
// but we should already have all of these in `universal_constraints`.
assert!(universal_constraints.contains(&(constraint.sup, constraint.sub)));
// Except for even more rare situations...
universal_constraints.insert((constraint.sup, constraint.sub));
} else {
universal_local_constraints.push(constraint);
}
Expand All @@ -72,7 +73,7 @@ impl<'tcx> OutlivesInfo<'tcx> {
local_constraints,
type_ascription_constraints,
location_constraints,
universal_constraints,
universal_constraints: universal_constraints.into_iter().collect(),
}
}

Expand Down
27 changes: 24 additions & 3 deletions mir-state-analysis/tests/top_crates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ fn run_on_crate(name: &str, version: &str) {
.collect::<PathBuf>(),
);
println!("Running: {prusti:?}");
let exit = std::process::Command::new(prusti)
// .env("PRUSTI_TEST_FREE_PCS", "true")
.env("PRUSTI_TEST_COUPLING_GRAPH", "true")

// FreePCS
let exit = std::process::Command::new(&prusti)
.env("PRUSTI_TEST_FREE_PCS", "true")
.env("PRUSTI_SKIP_UNSUPPORTED_FEATURES", "true")
// .env("PRUSTI_LOG", "debug")
.env("PRUSTI_NO_VERIFY_DEPS", "true")
Expand All @@ -75,6 +76,26 @@ fn run_on_crate(name: &str, version: &str) {
.status()
.unwrap();
assert!(exit.success());

// cargo clean
let exit = std::process::Command::new("cargo")
.arg("clean")
.current_dir(&dirname)
.status()
.unwrap();
assert!(exit.success());

// Coupling Graph
let exit = std::process::Command::new(&prusti)
.env("PRUSTI_TEST_COUPLING_GRAPH", "true")
.env("PRUSTI_SKIP_UNSUPPORTED_FEATURES", "true")
.env("PRUSTI_NO_VERIFY_DEPS", "true")
.env("PRUSTI_CAP_LINTS", "allow")
.env("PRUSTI_TOP_CRATES", "true")
.current_dir(&dirname)
.status()
.unwrap();
assert!(exit.success());
// std::fs::remove_dir_all(dirname).unwrap();
}

Expand Down
6 changes: 4 additions & 2 deletions prusti/src/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ impl prusti_rustc_interface::driver::Callbacks for PrustiCompilerCalls {
println!("Calculating FPCS for: {name} ({:?})", mir.span);
test_free_pcs(&mir, tcx);
}
} else if config::test_coupling_graph() {
}
if config::test_coupling_graph() {
for proc_id in env.get_annotated_procedures_and_types().0.iter() {
let mir = env.body.get_impure_fn_body_identity(proc_id.expect_local());
let facts = env
Expand All @@ -188,7 +189,8 @@ impl prusti_rustc_interface::driver::Callbacks for PrustiCompilerCalls {
println!("Calculating CG for: {name} ({:?})", mir.span);
test_coupling_graph(&*mir, &*facts, &*facts2, tcx, config::top_crates());
}
} else {
}
if !config::test_free_pcs() && !config::test_coupling_graph() {
verify(env, def_spec);
}
}
Expand Down

0 comments on commit 050bdb2

Please sign in to comment.