From b04b0f854b41e51ca9dd16727cd474a726b8a5ff Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 8 Nov 2023 19:12:42 -0500 Subject: [PATCH] Layer on our changes --- .../src/pubgrub/dependencies.rs | 8 ++++---- crates/puffin-resolver/src/resolver.rs | 7 +++---- rust-toolchain.toml | 2 +- vendor/pubgrub/src/internal/core.rs | 2 +- vendor/pubgrub/src/internal/incompatibility.rs | 4 ++-- .../pubgrub/src/internal/partial_solution.rs | 18 ++++++++++++++++++ vendor/pubgrub/src/lib.rs | 3 +-- vendor/pubgrub/src/range.rs | 2 +- vendor/pubgrub/src/solver.rs | 4 ++-- vendor/pubgrub/src/term.rs | 2 +- 10 files changed, 34 insertions(+), 18 deletions(-) diff --git a/crates/puffin-resolver/src/pubgrub/dependencies.rs b/crates/puffin-resolver/src/pubgrub/dependencies.rs index f59247384958..09bb7e57ba89 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. @@ -24,7 +24,7 @@ impl PubGrubDependencies { env: &'a MarkerEnvironment, ) -> Result { let mut dependencies = - DependencyConstraints::>::default(); + FxHashMap::>::default(); // Iterate over all declared requirements. for requirement in requirements { @@ -138,7 +138,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 d1af6e55a43d..1b2326156fe5 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,7 @@ 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 +249,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 +976,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 50fa4928b96f..5d56faf9ae08 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 ca1dec1c3519..d768482b61f5 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 fd33d6af0701..03a4cf3ba988 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 057dea134e2d..6a8a2bff5998 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 f41058bd738b..0a6c3369ac7e 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 be7ff250f532..a62413244c10 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 956e46be7364..a908b4a5285b 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 cf7aa6f7ba43..895afdfe0d74 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"),