@@ -223,7 +223,8 @@ fn sat_at_most_one(solver: &mut impl varisat::ExtendFormula, vars: &[varisat::Va
223
223
/// as compared to the real resolver.
224
224
///
225
225
/// For the subset of functionality that are currently made by `registry_strategy` this will,
226
- /// find a valid resolution if one exists.
226
+ /// find a valid resolution if one exists. The big thing that the real resolver does,
227
+ /// that this one does not do is work with features and optional dependencies.
227
228
///
228
229
/// The SAT library dose not optimize for the newer version,
229
230
/// so the selected packages may not match the real resolver.
@@ -346,14 +347,12 @@ impl SatResolve {
346
347
// if a `dep` is public then `p` `publicly_exports` all the things that the selected version `publicly_exports`
347
348
for & p in topological_order. iter ( ) {
348
349
if let Some ( deps) = version_selected_for. get ( & p) {
350
+ let mut p_exports = publicly_exports. remove ( & p. as_activations_key ( ) ) . unwrap ( ) ;
349
351
for ( _, versions) in deps. iter ( ) . filter ( |( d, _) | d. is_public ( ) ) {
350
352
for ( ver, sel) in versions {
351
- for ( & export_pid, & export_var) in publicly_exports[ ver] . clone ( ) . iter ( ) {
352
- let our_var = publicly_exports
353
- . entry ( p. as_activations_key ( ) )
354
- . or_default ( )
355
- . entry ( export_pid)
356
- . or_insert_with ( || cnf. new_var ( ) ) ;
353
+ for ( & export_pid, & export_var) in publicly_exports[ ver] . iter ( ) {
354
+ let our_var =
355
+ p_exports. entry ( export_pid) . or_insert_with ( || cnf. new_var ( ) ) ;
357
356
cnf. add_clause ( & [
358
357
sel. negative ( ) ,
359
358
export_var. negative ( ) ,
@@ -362,23 +361,22 @@ impl SatResolve {
362
361
}
363
362
}
364
363
}
364
+ publicly_exports. insert ( p. as_activations_key ( ) , p_exports) ;
365
365
}
366
366
}
367
367
368
368
// we already ensure there is only one version for each `activations_key` so we can think of
369
369
// `can_see` as being in terms of a set of `activations_key`s
370
- let mut can_see: HashMap < _ , HashMap < _ , varisat:: Var > > = HashMap :: new ( ) ;
370
+ // and if `p` `publicly_exports` `export` then it `can_see` `export`
371
+ let mut can_see: HashMap < _ , HashMap < _ , varisat:: Var > > = publicly_exports. clone ( ) ;
371
372
372
373
// if `p` has a `dep` that selected `ver` then it `can_see` all the things that the selected version `publicly_exports`
373
374
for ( & p, deps) in version_selected_for. iter ( ) {
374
- for ( _, versions) in deps {
375
+ let p_can_see = can_see. entry ( p. as_activations_key ( ) ) . or_default ( ) ;
376
+ for ( _, versions) in deps. iter ( ) . filter ( |( d, _) | !d. is_public ( ) ) {
375
377
for ( & ver, sel) in versions {
376
378
for ( & export_pid, & export_var) in publicly_exports[ & ver] . iter ( ) {
377
- let our_var = can_see
378
- . entry ( p. as_activations_key ( ) )
379
- . or_default ( )
380
- . entry ( export_pid)
381
- . or_insert_with ( || cnf. new_var ( ) ) ;
379
+ let our_var = p_can_see. entry ( export_pid) . or_insert_with ( || cnf. new_var ( ) ) ;
382
380
cnf. add_clause ( & [
383
381
sel. negative ( ) ,
384
382
export_var. negative ( ) ,
0 commit comments