Skip to content

Commit 46f1214

Browse files
authored
Initial divergences from upstream (#1)
1 parent acfbe99 commit 46f1214

File tree

7 files changed

+40
-14
lines changed

7 files changed

+40
-14
lines changed

src/internal/core.rs

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

27-
incompatibilities: Map<P, Vec<IncompId<P, VS>>>,
27+
pub incompatibilities: Map<P, Vec<IncompId<P, VS>>>,
2828

2929
/// Store the ids of incompatibilities that are already contradicted
3030
/// 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
@@ -31,14 +31,14 @@ use crate::version_set::VersionSet;
3131
#[derive(Debug, Clone)]
3232
pub struct Incompatibility<P: Package, VS: VersionSet> {
3333
package_terms: SmallMap<P, Term<VS>>,
34-
kind: Kind<P, VS>,
34+
pub kind: Kind<P, VS>,
3535
}
3636

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

4040
#[derive(Debug, Clone)]
41-
enum Kind<P: Package, VS: VersionSet> {
41+
pub enum Kind<P: Package, VS: VersionSet> {
4242
/// Initial incompatibility aiming at picking the root package for the first decision.
4343
NotRoot(P, VS::V),
4444
/// 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
@@ -217,8 +217,7 @@
217217
//! with a cache, you may want to know that some versions
218218
//! do not exist in your cache.
219219
220-
#![allow(clippy::rc_buffer)]
221-
#![warn(missing_docs)]
220+
#![allow(clippy::all, unreachable_pub)]
222221

223222
pub mod error;
224223
pub mod package;

src/range.rs

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

@@ -264,6 +264,15 @@ impl<V: Ord> Range<V> {
264264
}
265265
}
266266

267+
/// Implementation of [`Bound::as_ref`] which is currently marked as unstable.
268+
fn bound_as_ref<V>(bound: &Bound<V>) -> Bound<&V> {
269+
match bound {
270+
Included(v) => Included(v),
271+
Excluded(v) => Excluded(v),
272+
Unbounded => Unbounded,
273+
}
274+
}
275+
267276
fn valid_segment<T: PartialOrd>(start: &Bound<T>, end: &Bound<T>) -> bool {
268277
match (start, end) {
269278
(Included(s), Included(e)) => s <= e,
@@ -298,7 +307,7 @@ impl<V: Ord + Clone> Range<V> {
298307

299308
(Included(i), Excluded(e)) | (Excluded(e), Included(i)) if i <= e => Excluded(e),
300309
(Included(i), Excluded(e)) | (Excluded(e), Included(i)) if e < i => Included(i),
301-
(s, Unbounded) | (Unbounded, s) => s.as_ref(),
310+
(s, Unbounded) | (Unbounded, s) => bound_as_ref(s),
302311
_ => unreachable!(),
303312
}
304313
.cloned();
@@ -308,7 +317,7 @@ impl<V: Ord + Clone> Range<V> {
308317

309318
(Included(i), Excluded(e)) | (Excluded(e), Included(i)) if i >= e => Excluded(e),
310319
(Included(i), Excluded(e)) | (Excluded(e), Included(i)) if e > i => Included(i),
311-
(s, Unbounded) | (Unbounded, s) => s.as_ref(),
320+
(s, Unbounded) | (Unbounded, s) => bound_as_ref(s),
312321
_ => unreachable!(),
313322
}
314323
.cloned();
@@ -364,7 +373,7 @@ impl<V: Display + Eq> Display for Range<V> {
364373
} else {
365374
for (idx, segment) in self.segments.iter().enumerate() {
366375
if idx > 0 {
367-
write!(f, " | ")?;
376+
write!(f, ", ")?;
368377
}
369378
match segment {
370379
(Unbounded, Unbounded) => write!(f, "*")?,
@@ -373,9 +382,9 @@ impl<V: Display + Eq> Display for Range<V> {
373382
(Included(v), Unbounded) => write!(f, ">={v}")?,
374383
(Included(v), Included(b)) => {
375384
if v == b {
376-
write!(f, "{v}")?
385+
write!(f, "=={v}")?
377386
} else {
378-
write!(f, ">={v}, <={b}")?
387+
write!(f, ">={v},<={b}")?
379388
}
380389
}
381390
(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
@@ -73,8 +73,8 @@ use std::collections::{BTreeMap, BTreeSet as Set};
7373
use std::error::Error;
7474

7575
use crate::error::PubGrubError;
76-
use crate::internal::core::State;
77-
use crate::internal::incompatibility::Incompatibility;
76+
pub use crate::internal::core::State;
77+
pub use crate::internal::incompatibility::{Incompatibility, Kind};
7878
use crate::package::Package;
7979
use crate::type_aliases::{DependencyConstraints, Map, SelectedDependencies};
8080
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)