@@ -4,18 +4,17 @@ use std::collections::{HashMap, HashSet};
4
4
use std:: fmt;
5
5
use std:: fmt:: { Display , Formatter } ;
6
6
use std:: hash:: Hash ;
7
-
8
7
use std:: rc:: Rc ;
9
8
10
9
use itertools:: Itertools ;
11
10
use petgraph:: graph:: { DiGraph , EdgeIndex , EdgeReference , NodeIndex } ;
12
11
use petgraph:: visit:: { Bfs , DfsPostOrder , EdgeRef } ;
13
12
use petgraph:: Direction ;
14
13
15
- use crate :: internal:: id:: StringId ;
16
14
use crate :: {
17
- internal:: id:: { ClauseId , SolvableId , VersionSetId } ,
15
+ internal:: id:: { ClauseId , SolvableId , StringId , VersionSetId } ,
18
16
pool:: Pool ,
17
+ runtime:: AsyncRuntime ,
19
18
solver:: { clause:: Clause , Solver } ,
20
19
DependencyProvider , PackageName , SolvableDisplay , VersionSet ,
21
20
} ;
@@ -41,9 +40,9 @@ impl Problem {
41
40
}
42
41
43
42
/// Generates a graph representation of the problem (see [`ProblemGraph`] for details)
44
- pub fn graph < VS : VersionSet , N : PackageName , D : DependencyProvider < VS , N > > (
43
+ pub fn graph < VS : VersionSet , N : PackageName , D : DependencyProvider < VS , N > , RT : AsyncRuntime > (
45
44
& self ,
46
- solver : & Solver < VS , N , D > ,
45
+ solver : & Solver < VS , N , D , RT > ,
47
46
) -> ProblemGraph {
48
47
let mut graph = DiGraph :: < ProblemNode , ProblemEdge > :: default ( ) ;
49
48
let mut nodes: HashMap < SolvableId , NodeIndex > = HashMap :: default ( ) ;
@@ -53,7 +52,7 @@ impl Problem {
53
52
let unresolved_node = graph. add_node ( ProblemNode :: UnresolvedDependency ) ;
54
53
55
54
for clause_id in & self . clauses {
56
- let clause = & solver. clauses [ * clause_id] . kind ;
55
+ let clause = & solver. clauses . borrow ( ) [ * clause_id] . kind ;
57
56
match clause {
58
57
Clause :: InstallRoot => ( ) ,
59
58
Clause :: Excluded ( solvable, reason) => {
@@ -73,7 +72,7 @@ impl Problem {
73
72
& Clause :: Requires ( package_id, version_set_id) => {
74
73
let package_node = Self :: add_node ( & mut graph, & mut nodes, package_id) ;
75
74
76
- let candidates = solver. cache . get_or_cache_sorted_candidates ( version_set_id) . unwrap_or_else ( |_| {
75
+ let candidates = solver. async_runtime . block_on ( solver . cache . get_or_cache_sorted_candidates ( version_set_id) ) . unwrap_or_else ( |_| {
77
76
unreachable ! ( "The version set was used in the solver, so it must have been cached. Therefore cancellation is impossible here and we cannot get an `Err(...)`" )
78
77
} ) ;
79
78
if candidates. is_empty ( ) {
@@ -167,13 +166,15 @@ impl Problem {
167
166
N : PackageName + Display ,
168
167
D : DependencyProvider < VS , N > ,
169
168
M : SolvableDisplay < VS , N > ,
169
+ RT : AsyncRuntime ,
170
170
> (
171
171
& self ,
172
- solver : & ' a Solver < VS , N , D > ,
172
+ solver : & ' a Solver < VS , N , D , RT > ,
173
+ pool : Rc < Pool < VS , N > > ,
173
174
merged_solvable_display : & ' a M ,
174
175
) -> DisplayUnsat < ' a , VS , N , M > {
175
176
let graph = self . graph ( solver) ;
176
- DisplayUnsat :: new ( graph, solver . pool ( ) , merged_solvable_display)
177
+ DisplayUnsat :: new ( graph, pool, merged_solvable_display)
177
178
}
178
179
}
179
180
@@ -515,7 +516,7 @@ pub struct DisplayUnsat<'pool, VS: VersionSet, N: PackageName + Display, M: Solv
515
516
merged_candidates : HashMap < SolvableId , Rc < MergedProblemNode > > ,
516
517
installable_set : HashSet < NodeIndex > ,
517
518
missing_set : HashSet < NodeIndex > ,
518
- pool : & ' pool Pool < VS , N > ,
519
+ pool : Rc < Pool < VS , N > > ,
519
520
merged_solvable_display : & ' pool M ,
520
521
}
521
522
@@ -524,10 +525,10 @@ impl<'pool, VS: VersionSet, N: PackageName + Display, M: SolvableDisplay<VS, N>>
524
525
{
525
526
pub ( crate ) fn new (
526
527
graph : ProblemGraph ,
527
- pool : & ' pool Pool < VS , N > ,
528
+ pool : Rc < Pool < VS , N > > ,
528
529
merged_solvable_display : & ' pool M ,
529
530
) -> Self {
530
- let merged_candidates = graph. simplify ( pool) ;
531
+ let merged_candidates = graph. simplify ( & pool) ;
531
532
let installable_set = graph. get_installable_set ( ) ;
532
533
let missing_set = graph. get_missing_set ( ) ;
533
534
@@ -669,10 +670,10 @@ impl<'pool, VS: VersionSet, N: PackageName + Display, M: SolvableDisplay<VS, N>>
669
670
let version = if let Some ( merged) = self . merged_candidates . get ( & solvable_id) {
670
671
reported. extend ( merged. ids . iter ( ) . cloned ( ) ) ;
671
672
self . merged_solvable_display
672
- . display_candidates ( self . pool , & merged. ids )
673
+ . display_candidates ( & self . pool , & merged. ids )
673
674
} else {
674
675
self . merged_solvable_display
675
- . display_candidates ( self . pool , & [ solvable_id] )
676
+ . display_candidates ( & self . pool , & [ solvable_id] )
676
677
} ;
677
678
678
679
let excluded = graph
@@ -796,9 +797,9 @@ impl<VS: VersionSet, N: PackageName + Display, M: SolvableDisplay<VS, N>> fmt::D
796
797
writeln ! (
797
798
f,
798
799
"{indent}{} {} is locked, but another version is required as reported above" ,
799
- locked. name. display( self . pool) ,
800
+ locked. name. display( & self . pool) ,
800
801
self . merged_solvable_display
801
- . display_candidates( self . pool, & [ solvable_id] )
802
+ . display_candidates( & self . pool, & [ solvable_id] )
802
803
) ?;
803
804
}
804
805
ConflictCause :: Excluded => continue ,
0 commit comments