Skip to content

Commit 6bf38d0

Browse files
committed
Bugfix
1 parent 9e79e87 commit 6bf38d0

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

mir-state-analysis/src/coupling_graph/context/outlives_info/mod.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use prusti_rustc_interface::{
1010
borrow_set::BorrowData,
1111
consumers::{BorrowIndex, Borrows, OutlivesConstraint, PoloniusInput, RustcFacts},
1212
},
13-
data_structures::fx::FxHashMap,
13+
data_structures::fx::{FxHashMap, FxHashSet},
1414
dataflow::{Analysis, ResultsCursor},
1515
index::IndexVec,
1616
middle::{
@@ -30,7 +30,6 @@ pub struct OutlivesInfo<'tcx> {
3030
pub local_constraints: Vec<OutlivesConstraint<'tcx>>, // but with no location info
3131
pub type_ascription_constraints: Vec<OutlivesConstraint<'tcx>>,
3232
pub location_constraints: FxHashMap<Location, Vec<OutlivesConstraint<'tcx>>>,
33-
3433
pub universal_constraints: Vec<(RegionVid, RegionVid)>,
3534
}
3635

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

4545
let mut universal_local_constraints = Vec::new();
4646
let mut local_constraints = Vec::new();
@@ -57,7 +57,8 @@ impl<'tcx> OutlivesInfo<'tcx> {
5757
if ri.map.is_universal(constraint.sup) && ri.map.is_universal(constraint.sub) {
5858
// Not sure why the `region_inference_context` can rarely contain inter-universal constraints,
5959
// but we should already have all of these in `universal_constraints`.
60-
assert!(universal_constraints.contains(&(constraint.sup, constraint.sub)));
60+
// Except for even more rare situations...
61+
universal_constraints.insert((constraint.sup, constraint.sub));
6162
} else {
6263
universal_local_constraints.push(constraint);
6364
}
@@ -72,7 +73,7 @@ impl<'tcx> OutlivesInfo<'tcx> {
7273
local_constraints,
7374
type_ascription_constraints,
7475
location_constraints,
75-
universal_constraints,
76+
universal_constraints: universal_constraints.into_iter().collect(),
7677
}
7778
}
7879

mir-state-analysis/tests/top_crates.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ fn run_on_crate(name: &str, version: &str) {
6363
.collect::<PathBuf>(),
6464
);
6565
println!("Running: {prusti:?}");
66-
let exit = std::process::Command::new(prusti)
67-
// .env("PRUSTI_TEST_FREE_PCS", "true")
66+
let exit = std::process::Command::new(&prusti)
67+
.env("PRUSTI_TEST_FREE_PCS", "true")
6868
.env("PRUSTI_TEST_COUPLING_GRAPH", "true")
6969
.env("PRUSTI_SKIP_UNSUPPORTED_FEATURES", "true")
7070
// .env("PRUSTI_LOG", "debug")

prusti/src/callbacks.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn mir_borrowck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &BorrowCheckResu
3737
if !is_anon_const {
3838
let consumer_opts = if is_spec_fn(tcx, def_id.to_def_id())
3939
|| config::no_verify()
40-
|| config::test_free_pcs()
40+
|| (config::test_free_pcs() && !config::test_coupling_graph())
4141
{
4242
consumers::ConsumerOptions::RegionInferenceContext
4343
} else if config::test_coupling_graph() {
@@ -172,7 +172,8 @@ impl prusti_rustc_interface::driver::Callbacks for PrustiCompilerCalls {
172172
println!("Calculating FPCS for: {name} ({:?})", mir.span);
173173
test_free_pcs(&mir, tcx);
174174
}
175-
} else if config::test_coupling_graph() {
175+
}
176+
if config::test_coupling_graph() {
176177
for proc_id in env.get_annotated_procedures_and_types().0.iter() {
177178
let mir = env.body.get_impure_fn_body_identity(proc_id.expect_local());
178179
let facts = env
@@ -188,7 +189,8 @@ impl prusti_rustc_interface::driver::Callbacks for PrustiCompilerCalls {
188189
println!("Calculating CG for: {name} ({:?})", mir.span);
189190
test_coupling_graph(&*mir, &*facts, &*facts2, tcx, config::top_crates());
190191
}
191-
} else {
192+
}
193+
if !config::test_free_pcs() && !config::test_coupling_graph() {
192194
verify(env, def_spec);
193195
}
194196
}

0 commit comments

Comments
 (0)