@@ -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;
@@ -328,17 +328,9 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
328328 loop {
329329 // Run unit propagation.
330330 let result = state. pubgrub . unit_propagation ( state. next ) ;
331- // End the mutable borrow of `state.pubgrub`.
332- let result = result. map ( |conflict| {
333- conflict. map ( |conflict| {
334- conflict
335- . map ( |( package, term) | ( package, term. clone ( ) ) )
336- . collect :: < Vec < _ > > ( )
337- } )
338- } ) ;
339331 match result {
340332 Err ( err) => {
341- // If unit propagation failed, the is no solution.
333+ // If unit propagation failed, there is no solution.
342334 return Err ( self . convert_no_solution_err (
343335 err,
344336 state. fork_urls ,
@@ -349,14 +341,13 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
349341 & self . capabilities ,
350342 ) ) ;
351343 }
352- Ok ( Some ( conflict) ) => {
353- // Conflict tracking: If the version was rejected due to its dependencies,
354- // record culprit and affected.
355- state. record_conflict ( state. next , None , & conflict) ;
344+ Ok ( conflicts) => {
345+ for ( affected, incompatibility) in conflicts {
346+ // Conflict tracking: If there was a conflict, track affected and
347+ // culprit for all root cause incompatibilities
348+ state. record_conflict ( affected, None , incompatibility) ;
349+ }
356350 }
357- // There was no conflict, or we've already rejected the last version due to its
358- // dependencies.
359- Ok ( None ) => { }
360351 }
361352
362353 // Pre-visit all candidate packages, to allow metadata to be fetched in parallel.
@@ -2351,14 +2342,11 @@ impl ForkState {
23512342 ( package, version)
23522343 } ) ,
23532344 ) ;
2354- // End the mutable borrow of `self.pubgrub`
2355- let conflict: Option < Vec < _ > > =
2356- conflict. map ( |x| x. map ( |( package, term) | ( package, term. clone ( ) ) ) . collect ( ) ) ;
23572345
23582346 // Conflict tracking: If the version was rejected due to its dependencies, record culprit
23592347 // and affected.
2360- if let Some ( conflict ) = conflict {
2361- self . record_conflict ( for_package, Some ( for_version) , & conflict ) ;
2348+ if let Some ( incompatibility ) = conflict {
2349+ self . record_conflict ( for_package, Some ( for_version) , incompatibility ) ;
23622350 }
23632351 Ok ( ( ) )
23642352 }
@@ -2367,15 +2355,15 @@ impl ForkState {
23672355 & mut self ,
23682356 affected : Id < PubGrubPackage > ,
23692357 version : Option < & Version > ,
2370- conflict : & [ ( Id < PubGrubPackage > , Term < Ranges < Version > > ) ] ,
2358+ incompatibility : IncompId < PubGrubPackage , Ranges < Version > , UnavailableReason > ,
23712359 ) {
23722360 let mut culprit_is_real = false ;
2373- for ( incompatible, _term) in conflict {
2374- if * incompatible == affected {
2361+ for ( incompatible, _term) in self . pubgrub . incompatibility_store [ incompatibility ] . iter ( ) {
2362+ if incompatible == affected {
23752363 continue ;
23762364 }
23772365 if self . pubgrub . package_store [ affected] . name ( )
2378- == self . pubgrub . package_store [ * incompatible] . name ( )
2366+ == self . pubgrub . package_store [ incompatible] . name ( )
23792367 {
23802368 // Don't track conflicts between a marker package and the main package, when the
23812369 // marker is "copying" the obligations from the main package through conflicts.
@@ -2385,21 +2373,21 @@ impl ForkState {
23852373 let culprit_count = self
23862374 . conflict_tracker
23872375 . culprit
2388- . entry ( * incompatible)
2376+ . entry ( incompatible)
23892377 . or_default ( ) ;
23902378 * culprit_count += 1 ;
23912379 if * culprit_count == CONFLICT_THRESHOLD {
2392- self . conflict_tracker . depriotize . push ( * incompatible) ;
2380+ self . conflict_tracker . depriotize . push ( incompatible) ;
23932381 }
23942382 }
23952383 // Don't track conflicts between a marker package and the main package, when the
23962384 // marker is "copying" the obligations from the main package through conflicts.
23972385 if culprit_is_real {
23982386 if tracing:: enabled!( Level :: DEBUG ) {
2399- let incompatibility = conflict
2387+ let incompatibility = self . pubgrub . incompatibility_store [ incompatibility ]
24002388 . iter ( )
24012389 . map ( |( package, _term) | {
2402- format ! ( "{:?}" , self . pubgrub. package_store[ * package] . clone( ) , )
2390+ format ! ( "{:?}" , self . pubgrub. package_store[ package] . clone( ) , )
24032391 } )
24042392 . join ( ", " ) ;
24052393 if let Some ( version) = version {
0 commit comments