66use std:: collections:: HashSet as Set ;
77use std:: sync:: Arc ;
88
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 ,
1412} ;
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 } ;
2114
2215/// Current state of the PubGrub algorithm.
2316#[ derive( Clone ) ]
24- pub struct State < DP : DependencyProvider > {
17+ pub ( crate ) struct State < DP : DependencyProvider > {
2518 root_package : DP :: P ,
2619 root_version : DP :: V ,
2720
@@ -40,10 +33,10 @@ pub struct State<DP: DependencyProvider> {
4033
4134 /// Partial solution.
4235 /// TODO: remove pub.
43- pub partial_solution : PartialSolution < DP > ,
36+ pub ( crate ) partial_solution : PartialSolution < DP > ,
4437
4538 /// 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 > > ,
4740
4841 /// This is a stack of work to be done in `unit_propagation`.
4942 /// It can definitely be a local variable to that method, but
@@ -53,7 +46,7 @@ pub struct State<DP: DependencyProvider> {
5346
5447impl < DP : DependencyProvider > State < DP > {
5548 /// 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 {
5750 let mut incompatibility_store = Arena :: new ( ) ;
5851 let not_root_id = incompatibility_store. alloc ( Incompatibility :: not_root (
5952 root_package. clone ( ) ,
@@ -74,13 +67,13 @@ impl<DP: DependencyProvider> State<DP> {
7467 }
7568
7669 /// 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 > ) {
7871 let id = self . incompatibility_store . alloc ( incompat) ;
7972 self . merge_incompatibility ( id) ;
8073 }
8174
8275 /// Add an incompatibility to the state.
83- pub fn add_incompatibility_from_dependencies (
76+ pub ( crate ) fn add_incompatibility_from_dependencies (
8477 & mut self ,
8578 package : DP :: P ,
8679 version : DP :: V ,
@@ -105,7 +98,7 @@ impl<DP: DependencyProvider> State<DP> {
10598
10699 /// Unit propagation is the core mechanism of the solving algorithm.
107100 /// 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 > > {
109102 self . unit_propagation_buffer . clear ( ) ;
110103 self . unit_propagation_buffer . push ( package) ;
111104 while let Some ( current_package) = self . unit_propagation_buffer . pop ( ) {
@@ -202,7 +195,7 @@ impl<DP: DependencyProvider> State<DP> {
202195 & self . incompatibility_store ,
203196 ) ;
204197 match satisfier_search_result {
205- DifferentDecisionLevels {
198+ SatisfierSearch :: DifferentDecisionLevels {
206199 previous_satisfier_level,
207200 } => {
208201 let package = package. clone ( ) ;
@@ -214,7 +207,7 @@ impl<DP: DependencyProvider> State<DP> {
214207 log:: info!( "backtrack to {:?}" , previous_satisfier_level) ;
215208 return Ok ( ( package, current_incompat_id) ) ;
216209 }
217- SameDecisionLevels { satisfier_cause } => {
210+ SatisfierSearch :: SameDecisionLevels { satisfier_cause } => {
218211 let prior_cause = Incompatibility :: prior_cause (
219212 current_incompat_id,
220213 satisfier_cause,
@@ -248,10 +241,10 @@ impl<DP: DependencyProvider> State<DP> {
248241
249242 /// Add this incompatibility into the set of all incompatibilities.
250243 ///
251- /// Pub collapses identical dependencies from adjacent package versions
244+ /// PubGrub collapses identical dependencies from adjacent package versions
252245 /// into individual incompatibilities.
253246 /// 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.
255248 ///
256249 /// For example, rather than representing
257250 /// foo 1.0.0 depends on bar ^1.0.0 and
0 commit comments