diff --git a/crates/uv-resolver/src/pubgrub/priority.rs b/crates/uv-resolver/src/pubgrub/priority.rs index 9ad0ae2cce3a..e11aba0508f1 100644 --- a/crates/uv-resolver/src/pubgrub/priority.rs +++ b/crates/uv-resolver/src/pubgrub/priority.rs @@ -103,9 +103,12 @@ impl PubGrubPriorities { } } + /// Mark a package as prioritized by setting it to [`PubGrubPriority::ConflictEarly`], if it + /// doesn't have a higher priority already. + /// /// Returns whether the priority was changed, i.e., it's the first time we hit this condition /// for the package. - pub(crate) fn make_conflict_early(&mut self, package: &PubGrubPackage) -> bool { + pub(crate) fn mark_conflict_early(&mut self, package: &PubGrubPackage) -> bool { let next = self.0.len(); let Some(name) = package.name_no_root() else { // Not a correctness bug @@ -117,7 +120,10 @@ impl PubGrubPriorities { }; match self.0.entry(name.clone()) { std::collections::hash_map::Entry::Occupied(mut entry) => { - if matches!(entry.get(), PubGrubPriority::ConflictEarly(_)) { + if matches!( + entry.get(), + PubGrubPriority::ConflictEarly(_) | PubGrubPriority::Singleton(_) + ) { // Already in the right category return false; }; @@ -132,7 +138,12 @@ impl PubGrubPriorities { } } - pub(crate) fn make_conflict_late(&mut self, package: &PubGrubPackage) -> bool { + /// Mark a package as prioritized by setting it to [`PubGrubPriority::ConflictLate`], if it + /// doesn't have a higher priority already. + /// + /// Returns whether the priority was changed, i.e., it's the first time this package was + /// marked as conflicting above the threshold. + pub(crate) fn mark_conflict_late(&mut self, package: &PubGrubPackage) -> bool { let next = self.0.len(); let Some(name) = package.name_no_root() else { // Not a correctness bug @@ -147,7 +158,9 @@ impl PubGrubPriorities { // The ConflictEarly` match avoids infinite loops. if matches!( entry.get(), - PubGrubPriority::ConflictLate(_) | PubGrubPriority::ConflictEarly(_) + PubGrubPriority::ConflictLate(_) + | PubGrubPriority::ConflictEarly(_) + | PubGrubPriority::Singleton(_) ) { // Already in the right category return false; diff --git a/crates/uv-resolver/src/resolver/mod.rs b/crates/uv-resolver/src/resolver/mod.rs index 09d28a5579a6..d8f8494d337b 100644 --- a/crates/uv-resolver/src/resolver/mod.rs +++ b/crates/uv-resolver/src/resolver/mod.rs @@ -683,10 +683,10 @@ impl ResolverState ResolverState>, + prioritize: Vec>, /// How often a package was decided earlier and caused another package to be discarded. culprit: FxHashMap, usize>, /// Package(s) to be de-prioritized after the next unit propagation /// /// Distilled from `culprit` for fast checking in the hot loop. - depriotize: Vec>, + deprioritize: Vec>, } diff --git a/crates/uv/tests/it/lock.rs b/crates/uv/tests/it/lock.rs index 2c63756ed7f3..d1079bbc30d7 100644 --- a/crates/uv/tests/it/lock.rs +++ b/crates/uv/tests/it/lock.rs @@ -14433,7 +14433,7 @@ fn lock_explicit_default_index() -> Result<()> { DEBUG Adding transitive dependency for project==0.1.0: anyio* DEBUG Searching for a compatible version of anyio (*) DEBUG No compatible version found for: anyio - DEBUG Recording unit propagation conflict of anyio from incompatibility of (PubGrubPackage(Package { name: PackageName("project"), extra: None, dev: None, marker: true })) + DEBUG Recording unit propagation conflict of anyio from incompatibility of (project) DEBUG Searching for a compatible version of project @ file://[TEMP_DIR]/ (<0.1.0 | >0.1.0) DEBUG No compatible version found for: project × No solution found when resolving dependencies: