From 621c41bf13d969470488c999d7f3df76ac0097a5 Mon Sep 17 00:00:00 2001 From: Jacob Finkelman Date: Tue, 19 Nov 2024 17:56:44 +0000 Subject: [PATCH 1/2] the smallest change to bring back pre-79 behavior --- src/internal/partial_solution.rs | 12 ++++++++---- tests/examples.rs | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/internal/partial_solution.rs b/src/internal/partial_solution.rs index 44795582..121f80e5 100644 --- a/src/internal/partial_solution.rs +++ b/src/internal/partial_solution.rs @@ -485,12 +485,16 @@ impl PartialSolution { .get(satisfier_package) .expect("satisfier package not in incompat"); + let start_term = accum_term.intersection(&incompat_term.negate()); + let out = satisfier_pa.satisfier(satisfier_package, &start_term); + satisfied_map.insert( satisfier_package, - satisfier_pa.satisfier( - satisfier_package, - &accum_term.intersection(&incompat_term.negate()), - ), + if accum_term.subset_of(incompat_term) { + (None, 0, DecisionLevel(1)) + } else { + out + }, ); // Finally, let's identify the decision level of that previous satisfier. diff --git a/tests/examples.rs b/tests/examples.rs index fcc237c1..5dbbb409 100644 --- a/tests/examples.rs +++ b/tests/examples.rs @@ -237,8 +237,8 @@ fn confusing_with_lots_of_holes() { }; assert_eq!( &DefaultStringReporter::report(&derivation_tree), - r#"Because there is no available version for bar and foo 1 | 2 | 3 | 4 | 5 depends on bar, foo 1 | 2 | 3 | 4 | 5 is forbidden. -And because there is no version of foo in <1 | >1, <2 | >2, <3 | >3, <4 | >4, <5 | >5 and root 1 depends on foo, root 1 is forbidden."# + r#"Because foo 1 | 2 | 3 | 4 | 5 depends on bar and there is no version of foo in <1 | >1, <2 | >2, <3 | >3, <4 | >4, <5 | >5, foo depends on bar. +And because there is no available version for bar and root 1 depends on foo, root 1 is forbidden."# ); derivation_tree.collapse_no_versions(); assert_eq!( From 4ce8684aa6e156fea979ff9ab4336603a29d8ac2 Mon Sep 17 00:00:00 2001 From: Jacob Finkelman Date: Tue, 19 Nov 2024 17:56:44 +0000 Subject: [PATCH 2/2] only allocate the start term if it's needed --- src/internal/partial_solution.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/internal/partial_solution.rs b/src/internal/partial_solution.rs index 121f80e5..c46b83d8 100644 --- a/src/internal/partial_solution.rs +++ b/src/internal/partial_solution.rs @@ -485,15 +485,15 @@ impl PartialSolution { .get(satisfier_package) .expect("satisfier package not in incompat"); - let start_term = accum_term.intersection(&incompat_term.negate()); - let out = satisfier_pa.satisfier(satisfier_package, &start_term); - satisfied_map.insert( satisfier_package, if accum_term.subset_of(incompat_term) { (None, 0, DecisionLevel(1)) } else { - out + satisfier_pa.satisfier( + satisfier_package, + &accum_term.intersection(&incompat_term.negate()), + ) }, ); @@ -516,14 +516,16 @@ impl PackageAssignm package: &P, start_term: &Term, ) -> (Option>, u32, DecisionLevel) { - let empty = Term::empty(); // Indicate if we found a satisfier in the list of derivations, otherwise it will be the decision. let idx = self .dated_derivations .as_slice() .partition_point(|dd| !dd.accumulated_intersection.is_disjoint(start_term)); if let Some(dd) = self.dated_derivations.get(idx) { - debug_assert_eq!(dd.accumulated_intersection.intersection(start_term), empty); + debug_assert_eq!( + dd.accumulated_intersection.intersection(start_term), + Term::empty() + ); return (Some(dd.cause), dd.global_index, dd.decision_level); } // If it wasn't found in the derivations,