diff --git a/crates/puffin-resolver/src/pubgrub/dependencies.rs b/crates/puffin-resolver/src/pubgrub/dependencies.rs index f59247384..25b2e7f32 100644 --- a/crates/puffin-resolver/src/pubgrub/dependencies.rs +++ b/crates/puffin-resolver/src/pubgrub/dependencies.rs @@ -1,6 +1,6 @@ +use fxhash::FxHashMap; use itertools::Itertools; use pubgrub::range::Range; -use pubgrub::type_aliases::DependencyConstraints; use tracing::warn; use pep508_rs::{MarkerEnvironment, Requirement, VersionOrUrl}; @@ -12,7 +12,7 @@ use crate::pubgrub::{PubGrubPackage, PubGrubVersion}; use crate::ResolveError; #[derive(Debug)] -pub struct PubGrubDependencies(DependencyConstraints>); +pub struct PubGrubDependencies(FxHashMap>); impl PubGrubDependencies { /// Generate a set of `PubGrub` dependencies from a set of requirements. @@ -23,8 +23,7 @@ impl PubGrubDependencies { source: Option<&'a PackageName>, env: &'a MarkerEnvironment, ) -> Result { - let mut dependencies = - DependencyConstraints::>::default(); + let mut dependencies = FxHashMap::>::default(); // Iterate over all declared requirements. for requirement in requirements { @@ -138,7 +137,7 @@ impl PubGrubDependencies { } /// Convert a [`PubGrubDependencies`] to a [`DependencyConstraints`]. -impl From for DependencyConstraints> { +impl From for FxHashMap> { fn from(dependencies: PubGrubDependencies) -> Self { dependencies.0 } diff --git a/crates/puffin-resolver/src/resolver.rs b/crates/puffin-resolver/src/resolver.rs index d1af6e55a..89fbb6026 100644 --- a/crates/puffin-resolver/src/resolver.rs +++ b/crates/puffin-resolver/src/resolver.rs @@ -11,7 +11,6 @@ use fxhash::{FxHashMap, FxHashSet}; use pubgrub::error::PubGrubError; use pubgrub::range::Range; use pubgrub::solver::{Incompatibility, State}; -use pubgrub::type_aliases::DependencyConstraints; use tokio::select; use tokio::sync::Mutex; use tracing::{debug, error, trace}; @@ -236,7 +235,12 @@ impl<'a, Context: BuildContext + Sync> Resolver<'a, Context> { )); continue; } - Dependencies::Known(constraints) if constraints.contains_key(package) => { + Dependencies::Known(constraints) + if constraints + .clone() + .into_iter() + .any(|(dependency, _)| &dependency == package) => + { return Err(PubGrubError::SelfDependency { package: package.clone(), version: version.clone(), @@ -250,7 +254,7 @@ impl<'a, Context: BuildContext + Sync> Resolver<'a, Context> { let dep_incompats = state.add_incompatibility_from_dependencies( package.clone(), version.clone(), - &dependencies, + dependencies, ); state.partial_solution.add_version( @@ -977,5 +981,5 @@ enum Dependencies { /// Package dependencies are unavailable. Unknown, /// Container for all available package versions. - Known(DependencyConstraints>), + Known(FxHashMap>), } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 50fa4928b..5d56faf9a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.73" +channel = "nightly" diff --git a/vendor/pubgrub/src/internal/core.rs b/vendor/pubgrub/src/internal/core.rs index ca1dec1c3..d768482b6 100644 --- a/vendor/pubgrub/src/internal/core.rs +++ b/vendor/pubgrub/src/internal/core.rs @@ -24,7 +24,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/vendor/pubgrub/src/internal/incompatibility.rs b/vendor/pubgrub/src/internal/incompatibility.rs index fd33d6af0..03a4cf3ba 100644 --- a/vendor/pubgrub/src/internal/incompatibility.rs +++ b/vendor/pubgrub/src/internal/incompatibility.rs @@ -31,14 +31,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/vendor/pubgrub/src/internal/partial_solution.rs b/vendor/pubgrub/src/internal/partial_solution.rs index 057dea134..6a8a2bff5 100644 --- a/vendor/pubgrub/src/internal/partial_solution.rs +++ b/vendor/pubgrub/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/vendor/pubgrub/src/lib.rs b/vendor/pubgrub/src/lib.rs index f41058bd7..0a6c3369a 100644 --- a/vendor/pubgrub/src/lib.rs +++ b/vendor/pubgrub/src/lib.rs @@ -219,8 +219,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/vendor/pubgrub/src/range.rs b/vendor/pubgrub/src/range.rs index be7ff250f..a62413244 100644 --- a/vendor/pubgrub/src/range.rs +++ b/vendor/pubgrub/src/range.rs @@ -373,7 +373,7 @@ 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}")? } diff --git a/vendor/pubgrub/src/solver.rs b/vendor/pubgrub/src/solver.rs index 956e46be7..a908b4a52 100644 --- a/vendor/pubgrub/src/solver.rs +++ b/vendor/pubgrub/src/solver.rs @@ -73,8 +73,8 @@ use std::collections::{BTreeMap, BTreeSet as Set}; 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::{Map, SelectedDependencies}; use crate::version_set::VersionSet; diff --git a/vendor/pubgrub/src/term.rs b/vendor/pubgrub/src/term.rs index cf7aa6f7b..895afdfe0 100644 --- a/vendor/pubgrub/src/term.rs +++ b/vendor/pubgrub/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"),