@@ -13,7 +13,7 @@ use dashmap::DashMap;
1313use either:: Either ;
1414use futures:: { FutureExt , StreamExt } ;
1515use itertools:: Itertools ;
16- use pubgrub:: { Id , Incompatibility , Range , Ranges , State , Term } ;
16+ use pubgrub:: { Id , IncompId , Incompatibility , Range , Ranges , State } ;
1717use rustc_hash:: { FxHashMap , FxHashSet } ;
1818use tokio:: sync:: mpsc:: { self , Receiver , Sender } ;
1919use tokio:: sync:: oneshot;
@@ -336,17 +336,9 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
336336 } else {
337337 // Run unit propagation.
338338 let result = state. pubgrub . unit_propagation ( state. next ) ;
339- // End the mutable borrow of `state.pubgrub`.
340- let result = result. map ( |conflict| {
341- conflict. map ( |conflict| {
342- conflict
343- . map ( |( package, term) | ( package, term. clone ( ) ) )
344- . collect :: < Vec < _ > > ( )
345- } )
346- } ) ;
347339 match result {
348340 Err ( err) => {
349- // If unit propagation failed, the is no solution.
341+ // If unit propagation failed, there is no solution.
350342 return Err ( self . convert_no_solution_err (
351343 err,
352344 state. fork_urls ,
@@ -357,14 +349,13 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
357349 & self . capabilities ,
358350 ) ) ;
359351 }
360- Ok ( Some ( conflict) ) => {
361- // Conflict tracking: If the version was rejected due to its dependencies,
362- // record culprit and affected.
363- state. record_conflict ( state. next , None , & conflict) ;
352+ Ok ( conflicts) => {
353+ for ( affected, incompatibility) in conflicts {
354+ // Conflict tracking: If there was a conflict, track affected and
355+ // culprit for all root cause incompatibilities
356+ state. record_conflict ( affected, None , incompatibility) ;
357+ }
364358 }
365- // There was no conflict, or we've already rejected the last version due to its
366- // dependencies.
367- Ok ( None ) => { }
368359 }
369360
370361 // Pre-visit all candidate packages, to allow metadata to be fetched in parallel.
@@ -2412,14 +2403,11 @@ impl ForkState {
24122403 ( package, version)
24132404 } ) ,
24142405 ) ;
2415- // End the mutable borrow of `self.pubgrub`
2416- let conflict: Option < Vec < _ > > =
2417- conflict. map ( |x| x. map ( |( package, term) | ( package, term. clone ( ) ) ) . collect ( ) ) ;
24182406
24192407 // Conflict tracking: If the version was rejected due to its dependencies, record culprit
24202408 // and affected.
2421- if let Some ( conflict ) = conflict {
2422- self . record_conflict ( for_package, Some ( for_version) , & conflict ) ;
2409+ if let Some ( incompatibility ) = conflict {
2410+ self . record_conflict ( for_package, Some ( for_version) , incompatibility ) ;
24232411 }
24242412 Ok ( ( ) )
24252413 }
@@ -2428,15 +2416,15 @@ impl ForkState {
24282416 & mut self ,
24292417 affected : Id < PubGrubPackage > ,
24302418 version : Option < & Version > ,
2431- conflict : & [ ( Id < PubGrubPackage > , Term < Ranges < Version > > ) ] ,
2419+ incompatibility : IncompId < PubGrubPackage , Ranges < Version > , UnavailableReason > ,
24322420 ) {
24332421 let mut culprit_is_real = false ;
2434- for ( incompatible, _term) in conflict {
2435- if * incompatible == affected {
2422+ for ( incompatible, _term) in self . pubgrub . incompatibility_store [ incompatibility ] . iter ( ) {
2423+ if incompatible == affected {
24362424 continue ;
24372425 }
24382426 if self . pubgrub . package_store [ affected] . name ( )
2439- == self . pubgrub . package_store [ * incompatible] . name ( )
2427+ == self . pubgrub . package_store [ incompatible] . name ( )
24402428 {
24412429 // Don't track conflicts between a marker package and the main package, when the
24422430 // marker is "copying" the obligations from the main package through conflicts.
@@ -2446,21 +2434,21 @@ impl ForkState {
24462434 let culprit_count = self
24472435 . conflict_tracker
24482436 . culprit
2449- . entry ( * incompatible)
2437+ . entry ( incompatible)
24502438 . or_default ( ) ;
24512439 * culprit_count += 1 ;
24522440 if * culprit_count == CONFLICT_THRESHOLD {
2453- self . conflict_tracker . depriotize . push ( * incompatible) ;
2441+ self . conflict_tracker . depriotize . push ( incompatible) ;
24542442 }
24552443 }
24562444 // Don't track conflicts between a marker package and the main package, when the
24572445 // marker is "copying" the obligations from the main package through conflicts.
24582446 if culprit_is_real {
24592447 if tracing:: enabled!( Level :: DEBUG ) {
2460- let incompatibility = conflict
2448+ let incompatibility = self . pubgrub . incompatibility_store [ incompatibility ]
24612449 . iter ( )
24622450 . map ( |( package, _term) | {
2463- format ! ( "{:?}" , self . pubgrub. package_store[ * package] . clone( ) , )
2451+ format ! ( "{:?}" , self . pubgrub. package_store[ package] . clone( ) , )
24642452 } )
24652453 . join ( ", " ) ;
24662454 if let Some ( version) = version {
0 commit comments