6
6
use std:: collections:: HashSet as Set ;
7
7
use std:: sync:: Arc ;
8
8
9
- use crate :: error:: NoSolutionError ;
10
- use crate :: internal:: arena:: Arena ;
11
- use crate :: internal:: incompatibility:: { Incompatibility , Relation } ;
12
- use crate :: internal:: partial_solution:: SatisfierSearch :: {
13
- DifferentDecisionLevels , SameDecisionLevels ,
9
+ use crate :: internal:: {
10
+ Arena , DecisionLevel , IncompDpId , Incompatibility , PartialSolution , Relation , SatisfierSearch ,
11
+ SmallVec ,
14
12
} ;
15
- use crate :: internal:: partial_solution:: { DecisionLevel , PartialSolution } ;
16
- use crate :: internal:: small_vec:: SmallVec ;
17
- use crate :: report:: DerivationTree ;
18
- use crate :: solver:: DependencyProvider ;
19
- use crate :: type_aliases:: { IncompDpId , Map } ;
20
- use crate :: version_set:: VersionSet ;
13
+ use crate :: { DependencyProvider , DerivationTree , Map , NoSolutionError , VersionSet } ;
21
14
22
15
/// Current state of the PubGrub algorithm.
23
16
#[ derive( Clone ) ]
24
- pub struct State < DP : DependencyProvider > {
17
+ pub ( crate ) struct State < DP : DependencyProvider > {
25
18
root_package : DP :: P ,
26
19
root_version : DP :: V ,
27
20
@@ -40,10 +33,10 @@ pub struct State<DP: DependencyProvider> {
40
33
41
34
/// Partial solution.
42
35
/// TODO: remove pub.
43
- pub partial_solution : PartialSolution < DP > ,
36
+ pub ( crate ) partial_solution : PartialSolution < DP > ,
44
37
45
38
/// The store is the reference storage for all incompatibilities.
46
- pub incompatibility_store : Arena < Incompatibility < DP :: P , DP :: VS , DP :: M > > ,
39
+ pub ( crate ) incompatibility_store : Arena < Incompatibility < DP :: P , DP :: VS , DP :: M > > ,
47
40
48
41
/// This is a stack of work to be done in `unit_propagation`.
49
42
/// It can definitely be a local variable to that method, but
@@ -53,7 +46,7 @@ pub struct State<DP: DependencyProvider> {
53
46
54
47
impl < DP : DependencyProvider > State < DP > {
55
48
/// Initialization of PubGrub state.
56
- pub fn init ( root_package : DP :: P , root_version : DP :: V ) -> Self {
49
+ pub ( crate ) fn init ( root_package : DP :: P , root_version : DP :: V ) -> Self {
57
50
let mut incompatibility_store = Arena :: new ( ) ;
58
51
let not_root_id = incompatibility_store. alloc ( Incompatibility :: not_root (
59
52
root_package. clone ( ) ,
@@ -74,13 +67,13 @@ impl<DP: DependencyProvider> State<DP> {
74
67
}
75
68
76
69
/// Add an incompatibility to the state.
77
- pub fn add_incompatibility ( & mut self , incompat : Incompatibility < DP :: P , DP :: VS , DP :: M > ) {
70
+ pub ( crate ) fn add_incompatibility ( & mut self , incompat : Incompatibility < DP :: P , DP :: VS , DP :: M > ) {
78
71
let id = self . incompatibility_store . alloc ( incompat) ;
79
72
self . merge_incompatibility ( id) ;
80
73
}
81
74
82
75
/// Add an incompatibility to the state.
83
- pub fn add_incompatibility_from_dependencies (
76
+ pub ( crate ) fn add_incompatibility_from_dependencies (
84
77
& mut self ,
85
78
package : DP :: P ,
86
79
version : DP :: V ,
@@ -105,7 +98,7 @@ impl<DP: DependencyProvider> State<DP> {
105
98
106
99
/// Unit propagation is the core mechanism of the solving algorithm.
107
100
/// CF <https://github.com/dart-lang/pub/blob/master/doc/solver.md#unit-propagation>
108
- pub fn unit_propagation ( & mut self , package : DP :: P ) -> Result < ( ) , NoSolutionError < DP > > {
101
+ pub ( crate ) fn unit_propagation ( & mut self , package : DP :: P ) -> Result < ( ) , NoSolutionError < DP > > {
109
102
self . unit_propagation_buffer . clear ( ) ;
110
103
self . unit_propagation_buffer . push ( package) ;
111
104
while let Some ( current_package) = self . unit_propagation_buffer . pop ( ) {
@@ -202,7 +195,7 @@ impl<DP: DependencyProvider> State<DP> {
202
195
& self . incompatibility_store ,
203
196
) ;
204
197
match satisfier_search_result {
205
- DifferentDecisionLevels {
198
+ SatisfierSearch :: DifferentDecisionLevels {
206
199
previous_satisfier_level,
207
200
} => {
208
201
let package = package. clone ( ) ;
@@ -214,7 +207,7 @@ impl<DP: DependencyProvider> State<DP> {
214
207
log:: info!( "backtrack to {:?}" , previous_satisfier_level) ;
215
208
return Ok ( ( package, current_incompat_id) ) ;
216
209
}
217
- SameDecisionLevels { satisfier_cause } => {
210
+ SatisfierSearch :: SameDecisionLevels { satisfier_cause } => {
218
211
let prior_cause = Incompatibility :: prior_cause (
219
212
current_incompat_id,
220
213
satisfier_cause,
@@ -248,10 +241,10 @@ impl<DP: DependencyProvider> State<DP> {
248
241
249
242
/// Add this incompatibility into the set of all incompatibilities.
250
243
///
251
- /// Pub collapses identical dependencies from adjacent package versions
244
+ /// PubGrub collapses identical dependencies from adjacent package versions
252
245
/// into individual incompatibilities.
253
246
/// This substantially reduces the total number of incompatibilities
254
- /// and makes it much easier for Pub to reason about multiple versions of packages at once.
247
+ /// and makes it much easier for PubGrub to reason about multiple versions of packages at once.
255
248
///
256
249
/// For example, rather than representing
257
250
/// foo 1.0.0 depends on bar ^1.0.0 and
0 commit comments