diff --git a/examples/caching_dependency_provider.rs b/examples/caching_dependency_provider.rs index 683df4b5..ae04886a 100644 --- a/examples/caching_dependency_provider.rs +++ b/examples/caching_dependency_provider.rs @@ -32,18 +32,18 @@ impl> DependencyProvider for CachingDependenc ) -> Result, DP::Err> { let mut cache = self.cached_dependencies.borrow_mut(); match cache.get_dependencies(package, version) { - Ok(Dependencies::Unknown(_)) => { + Ok(Dependencies::Unavailable(_)) => { let dependencies = self.remote_dependencies.get_dependencies(package, version); match dependencies { - Ok(Dependencies::Known(dependencies)) => { + Ok(Dependencies::Available(dependencies)) => { cache.add_dependencies( package.clone(), version.clone(), dependencies.clone(), ); - Ok(Dependencies::Known(dependencies)) + Ok(Dependencies::Available(dependencies)) } - Ok(Dependencies::Unknown(reason)) => Ok(Dependencies::Unknown(reason)), + Ok(Dependencies::Unavailable(reason)) => Ok(Dependencies::Unavailable(reason)), error @ Err(_) => error, } } diff --git a/src/internal/incompatibility.rs b/src/internal/incompatibility.rs index ce45852b..6c4d2417 100644 --- a/src/internal/incompatibility.rs +++ b/src/internal/incompatibility.rs @@ -138,17 +138,6 @@ impl Incompatibilit } } - /// Create an incompatibility to remember - /// that a package version is not selectable - /// because its dependencies are not usable. - pub fn unusable_dependencies(package: P, version: VS::V, reason: M) -> Self { - let set = VS::singleton(version); - Self { - package_terms: SmallMap::One([(package.clone(), Term::Positive(set.clone()))]), - kind: Kind::Custom(package, set, reason), - } - } - /// Build an incompatibility from a given dependency. pub fn from_dependency(package: P, versions: VS, dep: (&P, &VS)) -> Self { let (p2, set2) = dep; @@ -383,12 +372,12 @@ pub mod tests { let mut store = Arena::new(); let i1 = store.alloc(Incompatibility { package_terms: SmallMap::Two([("p1", t1.clone()), ("p2", t2.negate())]), - kind: Kind::<_, _, String>::FromDependencyOf("p1", Range::full(), "p2", Range::full()) + kind: Kind::Custom("0", Range::full(), "foo".to_string()) }); let i2 = store.alloc(Incompatibility { package_terms: SmallMap::Two([("p2", t2), ("p3", t3.clone())]), - kind: Kind::<_, _, String>::FromDependencyOf("p2", Range::full(), "p3", Range::full()) + kind: Kind::Custom("0", Range::full(), "bar".to_string()) }); let mut i3 = Map::default(); diff --git a/src/solver.rs b/src/solver.rs index aca22aa8..52fef570 100644 --- a/src/solver.rs +++ b/src/solver.rs @@ -150,7 +150,7 @@ pub fn resolve( })?; let known_dependencies = match dependencies { - Dependencies::Unknown(reason) => { + Dependencies::Unavailable(reason) => { state.add_incompatibility(Incompatibility::custom_version( p.clone(), v.clone(), @@ -158,13 +158,13 @@ pub fn resolve( )); continue; } - Dependencies::Known(x) if x.contains_key(p) => { + Dependencies::Available(x) if x.contains_key(p) => { return Err(PubGrubError::SelfDependency { package: p.clone(), version: v, }); } - Dependencies::Known(x) => x, + Dependencies::Available(x) => x, }; // Add that package and version if the dependencies are not problematic. @@ -194,9 +194,9 @@ pub fn resolve( #[derive(Clone)] pub enum Dependencies { /// Package dependencies are unavailable with the reason why they are missing. - Unknown(M), + Unavailable(M), /// Container for all available package versions. - Known(DependencyConstraints), + Available(DependencyConstraints), } /// Trait that allows the algorithm to retrieve available packages and their dependencies. @@ -277,7 +277,7 @@ pub trait DependencyProvider { ) -> Result, Self::Err>; /// Retrieves the package dependencies. - /// Return [Dependencies::Unknown] if its dependencies are unknown. + /// Return [Dependencies::Unavailable] if its dependencies are not available. #[allow(clippy::type_complexity)] fn get_dependencies( &self, @@ -398,8 +398,10 @@ impl DependencyProvider for OfflineDependencyProvide version: &VS::V, ) -> Result, Infallible> { Ok(match self.dependencies(package, version) { - None => Dependencies::Unknown("its dependencies could not be determined".to_string()), - Some(dependencies) => Dependencies::Known(dependencies), + None => { + Dependencies::Unavailable("its dependencies could not be determined".to_string()) + } + Some(dependencies) => Dependencies::Available(dependencies), }) } } diff --git a/src/type_aliases.rs b/src/type_aliases.rs index 96aabbf4..8b893d18 100644 --- a/src/type_aliases.rs +++ b/src/type_aliases.rs @@ -17,7 +17,7 @@ pub type SelectedDependencies = /// Holds information about all possible versions a given package can accept. /// There is a difference in semantics between an empty map -/// inside [DependencyConstraints] and [Dependencies::Unknown](crate::solver::Dependencies::Unknown): +/// inside [DependencyConstraints] and [Dependencies::Unavailable](crate::solver::Dependencies::Unavailable): /// the former means the package has no dependency and it is a known fact, /// while the latter means they could not be fetched by the [DependencyProvider]. pub type DependencyConstraints = Map; diff --git a/tests/proptest.rs b/tests/proptest.rs index 356b443f..33e5cece 100644 --- a/tests/proptest.rs +++ b/tests/proptest.rs @@ -322,8 +322,8 @@ fn retain_versions( continue; } let deps = match dependency_provider.get_dependencies(n, v).unwrap() { - Dependencies::Unknown(_) => panic!(), - Dependencies::Known(deps) => deps, + Dependencies::Unavailable(_) => panic!(), + Dependencies::Available(deps) => deps, }; smaller_dependency_provider.add_dependencies(n.clone(), v.clone(), deps) } @@ -346,8 +346,8 @@ fn retain_dependencies( for n in dependency_provider.packages() { for v in dependency_provider.versions(n).unwrap() { let deps = match dependency_provider.get_dependencies(n, v).unwrap() { - Dependencies::Unknown(_) => panic!(), - Dependencies::Known(deps) => deps, + Dependencies::Unavailable(_) => panic!(), + Dependencies::Available(deps) => deps, }; smaller_dependency_provider.add_dependencies( n.clone(), @@ -517,8 +517,8 @@ proptest! { .get_dependencies(package, version) .unwrap() { - Dependencies::Unknown(_) => panic!(), - Dependencies::Known(d) => d.into_iter().collect(), + Dependencies::Unavailable(_) => panic!(), + Dependencies::Available(d) => d.into_iter().collect(), }; if !dependencies.is_empty() { to_remove.insert((package, **version, dep_idx.get(&dependencies).0)); diff --git a/tests/sat_dependency_provider.rs b/tests/sat_dependency_provider.rs index 36840f8e..ec496c1b 100644 --- a/tests/sat_dependency_provider.rs +++ b/tests/sat_dependency_provider.rs @@ -66,8 +66,8 @@ impl SatResolve { // active packages need each of there `deps` to be satisfied for (p, v, var) in &all_versions { let deps = match dp.get_dependencies(p, v).unwrap() { - Dependencies::Unknown(_) => panic!(), - Dependencies::Known(d) => d, + Dependencies::Unavailable(_) => panic!(), + Dependencies::Available(d) => d, }; for (p1, range) in &deps { let empty_vec = vec![];