Skip to content

Commit 4b8ff13

Browse files
committed
Initial divergences from upstream (#1)
1 parent d97491e commit 4b8ff13

File tree

7 files changed

+38
-12
lines changed

7 files changed

+38
-12
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
/// and will stay that way until the next conflict and backtrack is operated.

src/internal/incompatibility.rs

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

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

4242
#[derive(Debug, Clone)]
43-
enum Kind<P: Package, VS: VersionSet> {
43+
pub enum Kind<P: Package, VS: VersionSet> {
4444
/// Initial incompatibility aiming at picking the root package for the first decision.
4545
NotRoot(P, VS::V),
4646
/// 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
@@ -252,6 +252,24 @@ impl<P: Package, VS: VersionSet, Priority: Ord + Clone> PartialSolution<P, VS, P
252252
}
253253
}
254254

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

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@
220220
//! with a cache, you may want to know that some versions
221221
//! do not exist in your cache.
222222
223-
#![allow(clippy::rc_buffer)]
224-
#![warn(missing_docs)]
223+
#![allow(clippy::all, unreachable_pub)]
225224

226225
pub mod error;
227226
pub mod package;

src/range.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl<V: Ord> Range<V> {
196196
.segments
197197
.last()
198198
.expect("if there is a first element, there must be a last element");
199-
(start.as_ref(), end.1.as_ref())
199+
(bound_as_ref(start), bound_as_ref(&end.1))
200200
})
201201
}
202202

@@ -299,6 +299,15 @@ fn within_bounds<V: PartialOrd>(v: &V, segment: &Interval<V>) -> Ordering {
299299
Ordering::Greater
300300
}
301301

302+
/// Implementation of [`Bound::as_ref`] which is currently marked as unstable.
303+
fn bound_as_ref<V>(bound: &Bound<V>) -> Bound<&V> {
304+
match bound {
305+
Included(v) => Included(v),
306+
Excluded(v) => Excluded(v),
307+
Unbounded => Unbounded,
308+
}
309+
}
310+
302311
fn valid_segment<T: PartialOrd>(start: &Bound<T>, end: &Bound<T>) -> bool {
303312
match (start, end) {
304313
(Included(s), Included(e)) => s <= e,
@@ -505,7 +514,7 @@ impl<V: Display + Eq> Display for Range<V> {
505514
} else {
506515
for (idx, segment) in self.segments.iter().enumerate() {
507516
if idx > 0 {
508-
write!(f, " | ")?;
517+
write!(f, ", ")?;
509518
}
510519
match segment {
511520
(Unbounded, Unbounded) => write!(f, "*")?,
@@ -514,9 +523,9 @@ impl<V: Display + Eq> Display for Range<V> {
514523
(Included(v), Unbounded) => write!(f, ">={v}")?,
515524
(Included(v), Included(b)) => {
516525
if v == b {
517-
write!(f, "{v}")?
526+
write!(f, "=={v}")?
518527
} else {
519-
write!(f, ">={v}, <={b}")?
528+
write!(f, ">={v},<={b}")?
520529
}
521530
}
522531
(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)