@@ -34,14 +34,14 @@ use crate::version_set::VersionSet;
34
34
#[ derive( Debug , Clone ) ]
35
35
pub struct Incompatibility < P : Package , VS : VersionSet , M : Eq + Clone + Debug + Display > {
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 , M > ,
39
39
}
40
40
41
41
/// Type alias of unique identifiers for incompatibilities.
42
42
pub type IncompId < P , VS , M > = Id < Incompatibility < P , VS , M > > ;
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 , M : Eq + Clone + Debug + Display > {
47
47
/// Initial incompatibility aiming at picking the root package for the first decision.
@@ -138,6 +138,17 @@ impl<P: Package, VS: VersionSet, M: Eq + Clone + Debug + Display> Incompatibilit
138
138
}
139
139
}
140
140
141
+ /// Create an incompatibility to remember
142
+ /// that a package version is not selectable
143
+ /// because its dependencies are not usable.
144
+ pub fn unusable_dependencies ( package : P , version : VS :: V , reason : M ) -> Self {
145
+ let set = VS :: singleton ( version) ;
146
+ Self {
147
+ package_terms : SmallMap :: One ( [ ( package. clone ( ) , Term :: Positive ( set. clone ( ) ) ) ] ) ,
148
+ kind : Kind :: Custom ( package, set, reason) ,
149
+ }
150
+ }
151
+
141
152
/// Build an incompatibility from a given dependency.
142
153
pub fn from_dependency ( package : P , versions : VS , dep : ( & P , & VS ) ) -> Self {
143
154
let ( p2, set2) = dep;
@@ -154,8 +165,7 @@ impl<P: Package, VS: VersionSet, M: Eq + Clone + Debug + Display> Incompatibilit
154
165
}
155
166
}
156
167
157
- /// Return the two packages where this incompatibility when the incompatibility was created
158
- /// through a dependency edge between the two.
168
+ /// The two packages causing the incompatibility, if it was derived from dependencies.
159
169
pub fn as_dependency ( & self ) -> Option < ( & P , & P ) > {
160
170
match & self . kind {
161
171
Kind :: FromDependencyOf ( p1, _, p2, _) => Some ( ( p1, p2) ) ,
@@ -296,11 +306,9 @@ impl<P: Package, VS: VersionSet, M: Eq + Clone + Debug + Display> Incompatibilit
296
306
dep_set. clone ( ) ,
297
307
) )
298
308
}
299
- Kind :: Custom ( package, set, metadata) => DerivationTree :: External ( External :: Custom (
300
- package. clone ( ) ,
301
- set. clone ( ) ,
302
- metadata. clone ( ) ,
303
- ) ) ,
309
+ Kind :: Custom ( package, set, reason) => {
310
+ DerivationTree :: External ( External :: Custom ( package, set, reason) )
311
+ }
304
312
}
305
313
}
306
314
}
0 commit comments