From 03c71726fd23233c4bb7ab1ef6febd6c7d38bda2 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 26 Sep 2024 12:29:57 -0400 Subject: [PATCH] Remove unused thiserror variants in resolver --- crates/uv-resolver/src/error.rs | 22 ++-------------------- crates/uv-resolver/src/pubgrub/package.rs | 8 ++++---- crates/uv-resolver/src/resolver/mod.rs | 4 +--- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/crates/uv-resolver/src/error.rs b/crates/uv-resolver/src/error.rs index 420e7adb24c0..b5e5bdfc9f41 100644 --- a/crates/uv-resolver/src/error.rs +++ b/crates/uv-resolver/src/error.rs @@ -36,12 +36,6 @@ pub enum ResolveError { #[error("Attempted to wait on an unregistered task: `{_0}`")] UnregisteredTask(String), - #[error("Package metadata name `{metadata}` does not match given name `{given}`")] - NameMismatch { - given: PackageName, - metadata: PackageName, - }, - #[error(transparent)] PubGrubSpecifier(#[from] PubGrubSpecifierError), @@ -61,9 +55,6 @@ pub enum ResolveError { #[error("Package `{0}` attempted to resolve via URL: {1}. URL dependencies must be expressed as direct requirements or constraints. Consider adding `{0} @ {1}` to your dependencies or constraints file.")] DisallowedUrl(PackageName, String), - #[error("There are conflicting editable requirements for package `{0}`:\n- {1}\n- {2}")] - ConflictingEditables(PackageName, String, String), - #[error(transparent)] DistributionType(#[from] distribution_types::Error), @@ -89,14 +80,6 @@ pub enum ResolveError { #[error(transparent)] NoSolution(#[from] NoSolutionError), - #[error("{package} {version} depends on itself")] - SelfDependency { - /// Package whose dependencies we want. - package: Box, - /// Version of the package for which we want the dependencies. - version: Box, - }, - #[error("Attempted to construct an invalid version specifier")] InvalidVersion(#[from] pep440_rs::VersionSpecifierBuildError), @@ -106,9 +89,8 @@ pub enum ResolveError { #[error("found conflicting distribution in resolution: {0}")] ConflictingDistribution(ConflictingDistributionError), - /// Something unexpected happened. - #[error("{0}")] - Failure(String), + #[error("Package `{0}` is unavailable")] + PackageUnavailable(PackageName), } impl From> for ResolveError { diff --git a/crates/uv-resolver/src/pubgrub/package.rs b/crates/uv-resolver/src/pubgrub/package.rs index 9bb7bdc75a94..7d6b0a21b0c1 100644 --- a/crates/uv-resolver/src/pubgrub/package.rs +++ b/crates/uv-resolver/src/pubgrub/package.rs @@ -8,7 +8,7 @@ use crate::python_requirement::PythonRequirement; /// [`Arc`] wrapper around [`PubGrubPackageInner`] to make cloning (inside PubGrub) cheap. #[derive(Debug, Clone, Eq, Hash, PartialEq, PartialOrd, Ord)] -pub struct PubGrubPackage(Arc); +pub(crate) struct PubGrubPackage(Arc); impl Deref for PubGrubPackage { type Target = PubGrubPackageInner; @@ -38,7 +38,7 @@ impl From for PubGrubPackage { /// package (e.g., `black[colorama]`), and mark it as a dependency of the real package (e.g., /// `black`). We then discard the virtual packages at the end of the resolution process. #[derive(Debug, Clone, Eq, Hash, PartialEq, PartialOrd, Ord)] -pub enum PubGrubPackageInner { +pub(crate) enum PubGrubPackageInner { /// The root package, which is used to start the resolution process. Root(Option), /// A Python version. @@ -167,7 +167,7 @@ impl PubGrubPackage { } /// Returns `true` if this PubGrub package is a proxy package. - pub fn is_proxy(&self) -> bool { + pub(crate) fn is_proxy(&self) -> bool { matches!( &**self, PubGrubPackageInner::Extra { .. } @@ -219,7 +219,7 @@ impl PubGrubPackage { } #[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Hash, Ord)] -pub enum PubGrubPython { +pub(crate) enum PubGrubPython { /// The Python version installed in the current environment. Installed, /// The Python version for which dependencies are being resolved. diff --git a/crates/uv-resolver/src/resolver/mod.rs b/crates/uv-resolver/src/resolver/mod.rs index 8ec31f769d46..29c96fe23b4a 100644 --- a/crates/uv-resolver/src/resolver/mod.rs +++ b/crates/uv-resolver/src/resolver/mod.rs @@ -1216,9 +1216,7 @@ impl ResolverState