@@ -317,33 +317,44 @@ impl Ord for DepsFrame {
317
317
/// graph quickly and hopefully lock down what later larger dependencies can
318
318
/// use (those with more candidates).
319
319
#[ derive( Clone ) ]
320
- pub struct RemainingDeps ( usize , im_rc:: OrdSet < ( DepsFrame , usize ) > ) ;
320
+ pub struct RemainingDeps {
321
+ /// a monotonic counter, increased for each new insertion.
322
+ time : u32 ,
323
+ /// the data is augmented by the insertion time.
324
+ /// This insures that no two items will cmp eq.
325
+ /// Forcing the OrdSet into a multi set.
326
+ data : im_rc:: OrdSet < ( DepsFrame , u32 ) > ,
327
+ }
321
328
322
329
impl RemainingDeps {
323
330
pub fn new ( ) -> RemainingDeps {
324
- RemainingDeps ( 0 , im_rc:: OrdSet :: new ( ) )
331
+ RemainingDeps {
332
+ time : 0 ,
333
+ data : im_rc:: OrdSet :: new ( ) ,
334
+ }
325
335
}
326
336
pub fn push ( & mut self , x : DepsFrame ) {
327
- self . 1 . insert ( ( x, self . 0 ) ) ;
328
- self . 0 += 1 ;
337
+ let insertion_time = self . time ;
338
+ self . data . insert ( ( x, insertion_time) ) ;
339
+ self . time += 1 ;
329
340
}
330
341
pub fn pop_most_constrained ( & mut self ) -> Option < ( bool , ( Summary , ( usize , DepInfo ) ) ) > {
331
- while let Some ( ( mut deps_frame, i ) ) = self . 1 . remove_min ( ) {
342
+ while let Some ( ( mut deps_frame, insertion_time ) ) = self . data . remove_min ( ) {
332
343
let just_here_for_the_error_messages = deps_frame. just_for_error_messages ;
333
344
334
345
// Figure out what our next dependency to activate is, and if nothing is
335
346
// listed then we're entirely done with this frame (yay!) and we can
336
347
// move on to the next frame.
337
348
if let Some ( sibling) = deps_frame. remaining_siblings . next ( ) {
338
349
let parent = Summary :: clone ( & deps_frame. parent ) ;
339
- self . 1 . insert ( ( deps_frame, i ) ) ;
350
+ self . data . insert ( ( deps_frame, insertion_time ) ) ;
340
351
return Some ( ( just_here_for_the_error_messages, ( parent, sibling) ) ) ;
341
352
}
342
353
}
343
354
None
344
355
}
345
356
pub fn iter ( & mut self ) -> impl Iterator < Item = ( & PackageId , Dependency ) > {
346
- self . 1 . iter ( ) . flat_map ( |( other, _) | other. flatten ( ) )
357
+ self . data . iter ( ) . flat_map ( |( other, _) | other. flatten ( ) )
347
358
}
348
359
}
349
360
0 commit comments