@@ -56,25 +56,13 @@ enum AssignmentsIntersection<V: Version> {
56
56
Derivations ( Term < V > ) ,
57
57
}
58
58
59
- /// An assignment is either a decision: a chosen version for a package,
60
- /// or a derivation : a term specifying compatible versions for a package.
61
- /// We also record the incompatibility at the origin of a derivation, called its cause.
62
- /// TODO: Remove. I only added that to not change the code in core.rs (except reference &).
63
- #[ derive( Clone , PartialEq , Debug ) ]
64
- pub enum Assignment < P : Package , V : Version > {
65
- /// The decision.
66
- Decision {
67
- /// The package corresponding to the decision.
68
- package : P ,
69
- /// The decided version.
70
- version : V ,
59
+ #[ derive( Clone , Debug ) ]
60
+ pub enum SatisfierSearch < P : Package , V : Version > {
61
+ DifferentDecisionLevels {
62
+ previous_satisfier_level : DecisionLevel ,
71
63
} ,
72
- /// The derivation.
73
- Derivation {
74
- /// The package corresponding to the derivation.
75
- package : P ,
76
- /// Incompatibility cause of the derivation.
77
- cause : IncompId < P , V > ,
64
+ SameDecisionLevels {
65
+ satisfier_cause : IncompId < P , V > ,
78
66
} ,
79
67
}
80
68
@@ -286,12 +274,12 @@ impl<P: Package, V: Version> PartialSolution<P, V> {
286
274
. map ( |pa| pa. assignments_intersection . term ( ) )
287
275
}
288
276
289
- /// Find satisfier and previous satisfier decision level .
290
- pub fn find_satisfier_and_previous_satisfier_level (
277
+ /// Figure out if the satisfier and previous satisfier are of different decision levels .
278
+ pub fn satisfier_search (
291
279
& self ,
292
280
incompat : & Incompatibility < P , V > ,
293
281
store : & Arena < Incompatibility < P , V > > ,
294
- ) -> ( Assignment < P , V > , DecisionLevel , DecisionLevel ) {
282
+ ) -> ( P , SatisfierSearch < P , V > ) {
295
283
let satisfied_map = Self :: find_satisfier ( incompat, & self . package_assignments , store) ;
296
284
let ( satisfier_package, & ( satisfier_index, _, satisfier_decision_level) ) = satisfied_map
297
285
. iter ( )
@@ -305,27 +293,19 @@ impl<P: Package, V: Version> PartialSolution<P, V> {
305
293
& self . package_assignments ,
306
294
store,
307
295
) ;
308
- let satisfier_pa = self . package_assignments . get ( & satisfier_package) . unwrap ( ) ;
309
- let satisfier_assignment = if satisfier_index == satisfier_pa. dated_derivations . len ( ) {
310
- match & satisfier_pa. assignments_intersection {
311
- AssignmentsIntersection :: Decision ( ( _, version, _) ) => Assignment :: Decision {
312
- package : satisfier_package,
313
- version : version. clone ( ) ,
314
- } ,
315
- AssignmentsIntersection :: Derivations ( _) => panic ! ( "Must be a decision" ) ,
316
- }
296
+ if previous_satisfier_level < satisfier_decision_level {
297
+ let search_result = SatisfierSearch :: DifferentDecisionLevels {
298
+ previous_satisfier_level,
299
+ } ;
300
+ ( satisfier_package, search_result)
317
301
} else {
302
+ let satisfier_pa = self . package_assignments . get ( & satisfier_package) . unwrap ( ) ;
318
303
let dd = & satisfier_pa. dated_derivations [ satisfier_index] ;
319
- Assignment :: Derivation {
320
- package : satisfier_package,
321
- cause : dd. cause ,
322
- }
323
- } ;
324
- (
325
- satisfier_assignment,
326
- satisfier_decision_level,
327
- previous_satisfier_level,
328
- )
304
+ let search_result = SatisfierSearch :: SameDecisionLevels {
305
+ satisfier_cause : dd. cause ,
306
+ } ;
307
+ ( satisfier_package, search_result)
308
+ }
329
309
}
330
310
331
311
/// A satisfier is the earliest assignment in partial solution such that the incompatibility
0 commit comments