@@ -34,14 +34,14 @@ use crate::version_set::VersionSet;
34
34
#[ derive( Debug , Clone ) ]
35
35
pub struct Incompatibility < P : Package , VS : VersionSet > {
36
36
package_terms : SmallMap < P , Term < VS > > ,
37
- /// The reason for the incompatibility .
37
+ /// The reason why this version or combination of versions can't be selected .
38
38
pub kind : Kind < P , VS > ,
39
39
}
40
40
41
41
/// Type alias of unique identifiers for incompatibilities.
42
42
pub type IncompId < P , VS > = Id < Incompatibility < P , VS > > ;
43
43
44
- /// The reason for the incompatibility .
44
+ /// The reason why a version or combination of versions can't be selected .
45
45
#[ derive( Debug , Clone ) ]
46
46
pub enum Kind < P : Package , VS : VersionSet > {
47
47
/// Initial incompatibility aiming at picking the root package for the first decision.
@@ -50,6 +50,8 @@ pub enum Kind<P: Package, VS: VersionSet> {
50
50
NoVersions ( P , VS ) ,
51
51
/// Dependencies of the package are unavailable for versions in that range.
52
52
UnavailableDependencies ( P , VS ) ,
53
+ /// Dependencies of the package are unusable for versions in that range.
54
+ UnusableDependencies ( P , VS , Option < String > ) ,
53
55
/// Incompatibility coming from the dependencies of a given package.
54
56
FromDependencyOf ( P , VS , P , VS ) ,
55
57
/// Derived from two causes. Stores cause ids.
@@ -109,6 +111,17 @@ impl<P: Package, VS: VersionSet> Incompatibility<P, VS> {
109
111
}
110
112
}
111
113
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
+
112
125
/// Build an incompatibility from a given dependency.
113
126
pub fn from_dependency ( package : P , versions : VS , dep : ( & P , & VS ) ) -> Self {
114
127
let ( p2, set2) = dep;
@@ -125,8 +138,7 @@ impl<P: Package, VS: VersionSet> Incompatibility<P, VS> {
125
138
}
126
139
}
127
140
128
- /// Return the two packages where this incompatibility when the incompatibility was created
129
- /// through a dependency edge between the two.
141
+ /// The two packages causing the incompatibility, if it was derived from dependencies.
130
142
pub fn as_dependency ( & self ) -> Option < ( & P , & P ) > {
131
143
match & self . kind {
132
144
Kind :: FromDependencyOf ( p1, _, p2, _) => Some ( ( p1, p2) ) ,
@@ -262,6 +274,9 @@ impl<P: Package, VS: VersionSet> Incompatibility<P, VS> {
262
274
Kind :: UnavailableDependencies ( package, set) => {
263
275
DerivationTree :: External ( External :: UnavailableDependencies ( package, set) )
264
276
}
277
+ Kind :: UnusableDependencies ( package, set, reason) => {
278
+ DerivationTree :: External ( External :: UnusableDependencies ( package, set, reason) )
279
+ }
265
280
Kind :: FromDependencyOf ( package, set, dep_package, dep_set) => DerivationTree :: External (
266
281
External :: FromDependencyOf ( package, set, dep_package, dep_set) ,
267
282
) ,
0 commit comments