@@ -18,19 +18,21 @@ enum ConflictStoreTrie {
18
18
19
19
impl ConflictStoreTrie {
20
20
/// Finds any known set of conflicts, if any,
21
- /// which are activated in `cx` and pass the `filter` specified?
21
+ /// which are activated in `cx` and contain `PackageId` specified.
22
+ /// If more then one are activated, then it will return
23
+ /// one that will allow for the most jump-back.
22
24
fn find_conflicting (
23
25
& self ,
24
26
cx : & Context ,
25
27
must_contain : Option < PackageId > ,
26
- ) -> Option < & ConflictMap > {
28
+ ) -> Option < ( & ConflictMap , usize ) > {
27
29
match self {
28
30
ConflictStoreTrie :: Leaf ( c) => {
29
31
if must_contain. is_none ( ) {
30
32
// `is_conflicting` checks that all the elements are active,
31
33
// but we have checked each one by the recursion of this function.
32
34
debug_assert ! ( cx. is_conflicting( None , c) . is_some( ) ) ;
33
- Some ( c )
35
+ Some ( ( c , 0 ) )
34
36
} else {
35
37
// We did not find `must_contain`, so we need to keep looking.
36
38
None
@@ -43,11 +45,22 @@ impl ConflictStoreTrie {
43
45
. unwrap_or_else ( || m. range ( ..) )
44
46
{
45
47
// If the key is active, then we need to check all of the corresponding subtrie.
46
- if cx. is_active ( pid) . is_some ( ) {
47
- if let Some ( o ) =
48
+ if let Some ( age_this ) = cx. is_active ( pid) {
49
+ if let Some ( ( o , age_o ) ) =
48
50
store. find_conflicting ( cx, must_contain. filter ( |& f| f != pid) )
49
51
{
50
- assert ! ( out. replace( o) . is_none( ) ) ;
52
+ let age = if must_contain == Some ( pid) {
53
+ // all the results will include `must_contain`
54
+ // so the age of must_contain is not relevant to find the best result.
55
+ age_o
56
+ } else {
57
+ std:: cmp:: max ( age_this, age_o)
58
+ } ;
59
+ let out_age = out. get_or_insert ( ( o, age) ) . 1 ;
60
+ if out_age > age {
61
+ // we found one that can jump-back further so replace the out.
62
+ out = Some ( ( o, age) ) ;
63
+ }
51
64
}
52
65
}
53
66
// Else, if it is not active then there is no way any of the corresponding
@@ -138,7 +151,9 @@ impl ConflictCache {
138
151
}
139
152
}
140
153
/// Finds any known set of conflicts, if any,
141
- /// which are activated in `cx` and pass the `filter` specified?
154
+ /// which are activated in `cx` and contain `PackageId` specified.
155
+ /// If more then one are activated, then it will return
156
+ /// one that will allow for the most jump-back.
142
157
pub fn find_conflicting (
143
158
& self ,
144
159
cx : & Context ,
@@ -148,7 +163,8 @@ impl ConflictCache {
148
163
let out = self
149
164
. con_from_dep
150
165
. get ( dep) ?
151
- . find_conflicting ( cx, must_contain) ;
166
+ . find_conflicting ( cx, must_contain)
167
+ . map ( |( c, _) | c) ;
152
168
if cfg ! ( debug_assertions) {
153
169
if let Some ( f) = must_contain {
154
170
if let Some ( c) = & out {
0 commit comments