Skip to content

Commit

Permalink
Update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Nov 4, 2024
1 parent c96f18a commit 7824840
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 769 deletions.
99 changes: 50 additions & 49 deletions crates/uv-resolver/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ impl NoSolutionError {
/// The `[max]` sentinel is used to represent the maximum local version of a package, to
/// implement PEP 440 semantics for local version equality. For example, `1.0.0+foo` needs to
/// satisfy `==1.0.0`.
pub(crate) fn simplify_local_version_segments(
mut derivation_tree: ErrorTree,
) -> Option<ErrorTree> {
pub(crate) fn collapse_local_version_segments(derivation_tree: ErrorTree) -> ErrorTree {
/// Remove local versions sentinels (`+[max]`) from the given version ranges.
fn strip_sentinel(versions: &mut Ranges<Version>) {
versions.iter_mut().for_each(|(lower, upper)| {
Expand Down Expand Up @@ -321,58 +319,62 @@ impl NoSolutionError {
})
}

match derivation_tree {
DerivationTree::External(External::NotRoot(_, _)) => Some(derivation_tree),
DerivationTree::External(External::NoVersions(_, ref mut versions)) => {
if is_sentinel(versions) {
None
} else {
fn collapse(mut derivation_tree: ErrorTree) -> Option<ErrorTree> {
match derivation_tree {
DerivationTree::External(External::NotRoot(_, _)) => Some(derivation_tree),
DerivationTree::External(External::NoVersions(_, ref mut versions)) => {
if is_sentinel(versions) {
return None;
}

strip_sentinel(versions);
Some(derivation_tree)
}
}
DerivationTree::External(External::FromDependencyOf(
_,
ref mut versions1,
_,
ref mut versions2,
)) => {
strip_sentinel(versions1);
strip_sentinel(versions2);
Some(derivation_tree)
}
DerivationTree::External(External::Custom(_, ref mut versions, _)) => {
strip_sentinel(versions);
Some(derivation_tree)
}
DerivationTree::Derived(mut derived) => {
let cause1 = Self::simplify_local_version_segments((*derived.cause1).clone());
let cause2 = Self::simplify_local_version_segments((*derived.cause2).clone());
match (cause1, cause2) {
(Some(cause1), Some(cause2)) => Some(DerivationTree::Derived(Derived {
cause1: Arc::new(cause1),
cause2: Arc::new(cause2),
terms: std::mem::take(&mut derived.terms)
.into_iter()
.map(|(pkg, mut term)| {
match &mut term {
Term::Positive(versions) => {
strip_sentinel(versions);
}
Term::Negative(versions) => {
strip_sentinel(versions);
DerivationTree::External(External::FromDependencyOf(
_,
ref mut versions1,
_,
ref mut versions2,
)) => {
strip_sentinel(versions1);
strip_sentinel(versions2);
Some(derivation_tree)
}
DerivationTree::External(External::Custom(_, ref mut versions, _)) => {
strip_sentinel(versions);
Some(derivation_tree)
}
DerivationTree::Derived(mut derived) => {
let cause1 = collapse((*derived.cause1).clone());
let cause2 = collapse((*derived.cause2).clone());
match (cause1, cause2) {
(Some(cause1), Some(cause2)) => Some(DerivationTree::Derived(Derived {
cause1: Arc::new(cause1),
cause2: Arc::new(cause2),
terms: std::mem::take(&mut derived.terms)
.into_iter()
.map(|(pkg, mut term)| {
match &mut term {
Term::Positive(versions) => {
strip_sentinel(versions);
}
Term::Negative(versions) => {
strip_sentinel(versions);
}
}
}
(pkg, term)
})
.collect(),
shared_id: derived.shared_id,
})),
(Some(cause), None) | (None, Some(cause)) => Some(cause),
_ => None,
(pkg, term)
})
.collect(),
shared_id: derived.shared_id,
})),
(Some(cause), None) | (None, Some(cause)) => Some(cause),
_ => None,
}
}
}
}

collapse(derivation_tree).expect("derivation tree should contain at least one term")
}

/// Initialize a [`NoSolutionHeader`] for this error.
Expand Down Expand Up @@ -403,7 +405,6 @@ impl std::fmt::Display for NoSolutionError {
display_tree(&tree, "Resolver derivation tree before reduction");
}

// simplify_local_version_segments(&mut tree);
collapse_no_versions_of_workspace_members(&mut tree, &self.workspace_members);

if self.workspace_members.len() == 1 {
Expand Down
10 changes: 0 additions & 10 deletions crates/uv-resolver/src/pubgrub/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,16 +496,6 @@ impl PubGrubReportFormatter<'_> {
}
}

// fn simplify_locals<'a>(
// &self,
// set: &'a Range<Version>,
// ) -> Cow<'a, Range<Version>> {
// // for (lower, upper) in set.iter() {
// //
// // }
// Cow::Owned(Range::from((Bound::Included(Version::new([0])), Bound::Excluded(Version::new([1])))))
// }

/// Generate the [`PubGrubHints`] for a derivation tree.
///
/// The [`PubGrubHints`] help users resolve errors by providing additional context or modifying
Expand Down
5 changes: 2 additions & 3 deletions crates/uv-resolver/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1952,10 +1952,9 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
index_locations: &IndexLocations,
index_capabilities: &IndexCapabilities,
) -> ResolveError {
err = NoSolutionError::simplify_local_version_segments(NoSolutionError::collapse_proxies(
err = NoSolutionError::collapse_local_version_segments(NoSolutionError::collapse_proxies(
err,
))
.unwrap();
));

let mut unavailable_packages = FxHashMap::default();
for package in err.packages() {
Expand Down
Loading

0 comments on commit 7824840

Please sign in to comment.