@@ -34,12 +34,14 @@ use crate::version_set::VersionSet;
3434#[ derive( Debug , Clone ) ]
3535pub struct Incompatibility < P : Package , VS : VersionSet > {
3636 package_terms : SmallMap < P , Term < VS > > ,
37+ /// The reason why this version or combination of versions can't be selected.
3738 pub kind : Kind < P , VS > ,
3839}
3940
4041/// Type alias of unique identifiers for incompatibilities.
4142pub type IncompId < P , VS > = Id < Incompatibility < P , VS > > ;
4243
44+ /// The reason why a version or combination of versions can't be selected.
4345#[ derive( Debug , Clone ) ]
4446pub enum Kind < P : Package , VS : VersionSet > {
4547 /// Initial incompatibility aiming at picking the root package for the first decision.
@@ -48,6 +50,8 @@ pub enum Kind<P: Package, VS: VersionSet> {
4850 NoVersions ( P , VS ) ,
4951 /// Dependencies of the package are unavailable for versions in that range.
5052 UnavailableDependencies ( P , VS ) ,
53+ /// Dependencies of the package are unusable for versions in that range.
54+ UnusableDependencies ( P , VS , Option < String > ) ,
5155 /// Incompatibility coming from the dependencies of a given package.
5256 FromDependencyOf ( P , VS , P , VS ) ,
5357 /// Derived from two causes. Stores cause ids.
@@ -107,6 +111,17 @@ impl<P: Package, VS: VersionSet> Incompatibility<P, VS> {
107111 }
108112 }
109113
114+ /// Create an incompatibility to remember
115+ /// that a package version is not selectable
116+ /// because its dependencies are not usable.
117+ pub fn unusable_dependencies ( package : P , version : VS :: V , reason : Option < String > ) -> Self {
118+ let set = VS :: singleton ( version) ;
119+ Self {
120+ package_terms : SmallMap :: One ( [ ( package. clone ( ) , Term :: Positive ( set. clone ( ) ) ) ] ) ,
121+ kind : Kind :: UnusableDependencies ( package, set, reason) ,
122+ }
123+ }
124+
110125 /// Build an incompatibility from a given dependency.
111126 pub fn from_dependency ( package : P , versions : VS , dep : ( & P , & VS ) ) -> Self {
112127 let ( p2, set2) = dep;
@@ -123,6 +138,7 @@ impl<P: Package, VS: VersionSet> Incompatibility<P, VS> {
123138 }
124139 }
125140
141+ /// The two packages causing the incompatibility, if it was derived from dependencies.
126142 pub fn as_dependency ( & self ) -> Option < ( & P , & P ) > {
127143 match & self . kind {
128144 Kind :: FromDependencyOf ( p1, _, p2, _) => Some ( ( p1, p2) ) ,
@@ -255,6 +271,9 @@ impl<P: Package, VS: VersionSet> Incompatibility<P, VS> {
255271 Kind :: UnavailableDependencies ( package, set) => {
256272 DerivationTree :: External ( External :: UnavailableDependencies ( package, set) )
257273 }
274+ Kind :: UnusableDependencies ( package, set, reason) => {
275+ DerivationTree :: External ( External :: UnusableDependencies ( package, set, reason) )
276+ }
258277 Kind :: FromDependencyOf ( package, set, dep_package, dep_set) => DerivationTree :: External (
259278 External :: FromDependencyOf ( package, set, dep_package, dep_set) ,
260279 ) ,
0 commit comments