diff --git a/src/internal/core.rs b/src/internal/core.rs index c53f6a35..7116c7b8 100644 --- a/src/internal/core.rs +++ b/src/internal/core.rs @@ -25,7 +25,7 @@ pub struct State { root_package: P, root_version: VS::V, - incompatibilities: Map>>, + pub incompatibilities: Map>>, /// Store the ids of incompatibilities that are already contradicted /// and will stay that way until the next conflict and backtrack is operated. diff --git a/src/internal/incompatibility.rs b/src/internal/incompatibility.rs index 1c8add0a..80d403fd 100644 --- a/src/internal/incompatibility.rs +++ b/src/internal/incompatibility.rs @@ -33,14 +33,14 @@ use crate::version_set::VersionSet; #[derive(Debug, Clone)] pub struct Incompatibility { package_terms: SmallMap>, - kind: Kind, + pub kind: Kind, } /// Type alias of unique identifiers for incompatibilities. pub type IncompId = Id>; #[derive(Debug, Clone)] -enum Kind { +pub enum Kind { /// Initial incompatibility aiming at picking the root package for the first decision. NotRoot(P, VS::V), /// There are no versions in the given range for this package. diff --git a/src/internal/partial_solution.rs b/src/internal/partial_solution.rs index 057dea13..6a8a2bff 100644 --- a/src/internal/partial_solution.rs +++ b/src/internal/partial_solution.rs @@ -252,6 +252,24 @@ impl PartialSolution impl Iterator { + let check_all = self.changed_this_decision_level + == self.current_decision_level.0.saturating_sub(1) as usize; + let current_decision_level = self.current_decision_level; + self.package_assignments + .get_range(self.changed_this_decision_level..) + .unwrap() + .iter() + .filter(move |(_, pa)| { + // We only actually need to update the package if its Been changed + // since the last time we called prioritize. + // Which means it's highest decision level is the current decision level, + // or if we backtracked in the mean time. + check_all || pa.highest_decision_level == current_decision_level + }) + .filter_map(|(p, pa)| pa.assignments_intersection.potential_package_filter(p)) + } + pub fn pick_highest_priority_pkg( &mut self, prioritizer: impl Fn(&P, &VS) -> Priority, diff --git a/src/lib.rs b/src/lib.rs index 11c20e80..7a121bc6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -220,8 +220,7 @@ //! with a cache, you may want to know that some versions //! do not exist in your cache. -#![allow(clippy::rc_buffer)] -#![warn(missing_docs)] +#![allow(clippy::all, unreachable_pub)] pub mod error; pub mod package; diff --git a/src/range.rs b/src/range.rs index e3ba82e2..25c69511 100644 --- a/src/range.rs +++ b/src/range.rs @@ -196,7 +196,7 @@ impl Range { .segments .last() .expect("if there is a first element, there must be a last element"); - (start.as_ref(), end.1.as_ref()) + (bound_as_ref(start), bound_as_ref(&end.1)) }) } @@ -299,6 +299,15 @@ fn within_bounds(v: &V, segment: &Interval) -> Ordering { Ordering::Greater } +/// Implementation of [`Bound::as_ref`] which is currently marked as unstable. +fn bound_as_ref(bound: &Bound) -> Bound<&V> { + match bound { + Included(v) => Included(v), + Excluded(v) => Excluded(v), + Unbounded => Unbounded, + } +} + fn valid_segment(start: &Bound, end: &Bound) -> bool { match (start, end) { (Included(s), Included(e)) => s <= e, @@ -505,7 +514,7 @@ impl Display for Range { } else { for (idx, segment) in self.segments.iter().enumerate() { if idx > 0 { - write!(f, " | ")?; + write!(f, ", ")?; } match segment { (Unbounded, Unbounded) => write!(f, "*")?, @@ -514,9 +523,9 @@ impl Display for Range { (Included(v), Unbounded) => write!(f, ">={v}")?, (Included(v), Included(b)) => { if v == b { - write!(f, "{v}")? + write!(f, "=={v}")? } else { - write!(f, ">={v}, <={b}")? + write!(f, ">={v},<={b}")? } } (Included(v), Excluded(b)) => write!(f, ">={v}, <{b}")?, diff --git a/src/solver.rs b/src/solver.rs index 9ac2edfe..dc944960 100644 --- a/src/solver.rs +++ b/src/solver.rs @@ -75,8 +75,8 @@ use std::convert::Infallible; use std::error::Error; use crate::error::PubGrubError; -use crate::internal::core::State; -use crate::internal::incompatibility::Incompatibility; +pub use crate::internal::core::State; +pub use crate::internal::incompatibility::{Incompatibility, Kind}; use crate::package::Package; use crate::type_aliases::{DependencyConstraints, Map, SelectedDependencies}; use crate::version_set::VersionSet; diff --git a/src/term.rs b/src/term.rs index 3a9906bd..964e80ee 100644 --- a/src/term.rs +++ b/src/term.rs @@ -64,7 +64,7 @@ impl Term { /// Unwrap the set contained in a positive term. /// Will panic if used on a negative set. - pub(crate) fn unwrap_positive(&self) -> &VS { + pub fn unwrap_positive(&self) -> &VS { match self { Self::Positive(set) => set, _ => panic!("Negative term cannot unwrap positive set"), diff --git a/tests/examples.rs b/tests/examples.rs index f968bba1..8bcc8c74 100644 --- a/tests/examples.rs +++ b/tests/examples.rs @@ -231,12 +231,12 @@ 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 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."# ); derivation_tree.collapse_no_versions(); assert_eq!( &DefaultStringReporter::report(&derivation_tree), - "Because foo depends on bar and root 1 depends on foo, root 1 is forbidden." + "Because foo depends on bar and root ==1 depends on foo, root ==1 is forbidden." ); }