Skip to content

Commit 26db142

Browse files
zaniebkonstin
authored andcommitted
Initial divergences from upstream (#1)
1 parent 3549dc5 commit 26db142

File tree

7 files changed

+38
-10
lines changed

7 files changed

+38
-10
lines changed

src/internal/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub struct State<P: Package, VS: VersionSet, Priority: Ord + Clone> {
2525
root_package: P,
2626
root_version: VS::V,
2727

28-
incompatibilities: Map<P, Vec<IncompId<P, VS>>>,
28+
pub incompatibilities: Map<P, Vec<IncompId<P, VS>>>,
2929

3030
/// Store the ids of incompatibilities that are already contradicted.
3131
/// For each one keep track of the decision level when it was found to be contradicted.

src/internal/incompatibility.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ use crate::version_set::VersionSet;
3434
#[derive(Debug, Clone)]
3535
pub struct Incompatibility<P: Package, VS: VersionSet> {
3636
package_terms: SmallMap<P, Term<VS>>,
37-
kind: Kind<P, VS>,
37+
pub kind: Kind<P, VS>,
3838
}
3939

4040
/// Type alias of unique identifiers for incompatibilities.
4141
pub type IncompId<P, VS> = Id<Incompatibility<P, VS>>;
4242

4343
#[derive(Debug, Clone)]
44-
enum Kind<P: Package, VS: VersionSet> {
44+
pub enum Kind<P: Package, VS: VersionSet> {
4545
/// Initial incompatibility aiming at picking the root package for the first decision.
4646
NotRoot(P, VS::V),
4747
/// There are no versions in the given range for this package.

src/internal/partial_solution.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,24 @@ impl<P: Package, VS: VersionSet, Priority: Ord + Clone> PartialSolution<P, VS, P
257257
}
258258
}
259259

260+
pub fn prioritized_packages(&self) -> impl Iterator<Item = (&P, &VS)> {
261+
let check_all = self.changed_this_decision_level
262+
== self.current_decision_level.0.saturating_sub(1) as usize;
263+
let current_decision_level = self.current_decision_level;
264+
self.package_assignments
265+
.get_range(self.changed_this_decision_level..)
266+
.unwrap()
267+
.iter()
268+
.filter(move |(_, pa)| {
269+
// We only actually need to update the package if its Been changed
270+
// since the last time we called prioritize.
271+
// Which means it's highest decision level is the current decision level,
272+
// or if we backtracked in the mean time.
273+
check_all || pa.highest_decision_level == current_decision_level
274+
})
275+
.filter_map(|(p, pa)| pa.assignments_intersection.potential_package_filter(p))
276+
}
277+
260278
pub fn pick_highest_priority_pkg(
261279
&mut self,
262280
prioritizer: impl Fn(&P, &VS) -> Priority,

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@
221221
//! do not exist in your cache.
222222
223223
#![warn(missing_docs)]
224+
#![allow(clippy::all, unreachable_pub)]
224225

225226
pub mod error;
226227
pub mod package;

src/range.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl<V: Ord> Range<V> {
217217
.segments
218218
.last()
219219
.expect("if there is a first element, there must be a last element");
220-
(start.as_ref(), end.1.as_ref())
220+
(bound_as_ref(start), bound_as_ref(&end.1))
221221
})
222222
}
223223

@@ -335,6 +335,15 @@ fn within_bounds<V: PartialOrd>(v: &V, segment: &Interval<V>) -> Ordering {
335335
Ordering::Greater
336336
}
337337

338+
/// Implementation of [`Bound::as_ref`] which is currently marked as unstable.
339+
fn bound_as_ref<V>(bound: &Bound<V>) -> Bound<&V> {
340+
match bound {
341+
Included(v) => Included(v),
342+
Excluded(v) => Excluded(v),
343+
Unbounded => Unbounded,
344+
}
345+
}
346+
338347
fn valid_segment<T: PartialOrd>(start: &Bound<T>, end: &Bound<T>) -> bool {
339348
match (start, end) {
340349
(Included(s), Included(e)) => s <= e,
@@ -561,7 +570,7 @@ impl<V: Display + Eq> Display for Range<V> {
561570
} else {
562571
for (idx, segment) in self.segments.iter().enumerate() {
563572
if idx > 0 {
564-
write!(f, " | ")?;
573+
write!(f, ", ")?;
565574
}
566575
match segment {
567576
(Unbounded, Unbounded) => write!(f, "*")?,
@@ -570,9 +579,9 @@ impl<V: Display + Eq> Display for Range<V> {
570579
(Included(v), Unbounded) => write!(f, ">={v}")?,
571580
(Included(v), Included(b)) => {
572581
if v == b {
573-
write!(f, "{v}")?
582+
write!(f, "=={v}")?
574583
} else {
575-
write!(f, ">={v}, <={b}")?
584+
write!(f, ">={v},<={b}")?
576585
}
577586
}
578587
(Included(v), Excluded(b)) => write!(f, ">={v}, <{b}")?,

src/solver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ use std::convert::Infallible;
7575
use std::error::Error;
7676

7777
use crate::error::PubGrubError;
78-
use crate::internal::core::State;
79-
use crate::internal::incompatibility::Incompatibility;
78+
pub use crate::internal::core::State;
79+
pub use crate::internal::incompatibility::{Incompatibility, Kind};
8080
use crate::package::Package;
8181
use crate::type_aliases::{DependencyConstraints, Map, SelectedDependencies};
8282
use crate::version_set::VersionSet;

src/term.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl<VS: VersionSet> Term<VS> {
6464

6565
/// Unwrap the set contained in a positive term.
6666
/// Will panic if used on a negative set.
67-
pub(crate) fn unwrap_positive(&self) -> &VS {
67+
pub fn unwrap_positive(&self) -> &VS {
6868
match self {
6969
Self::Positive(set) => set,
7070
_ => panic!("Negative term cannot unwrap positive set"),

0 commit comments

Comments
 (0)