Skip to content

Commit a516d5b

Browse files
committed
if we are a descendant of the trigger of the problem.
The best generalization of this is to let things bubble up and let `jumpback_critical_id` figure this out.
1 parent fd27ee7 commit a516d5b

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/cargo/core/resolver/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ fn activate_deps_loop(
303303
&cx,
304304
registry,
305305
&mut past_conflicting_activations,
306+
&parent,
306307
&dep,
307308
&conflicting_activations,
308309
) {
@@ -859,6 +860,7 @@ fn generalize_conflicting(
859860
cx: &Context,
860861
registry: &mut RegistryQueryer<'_>,
861862
past_conflicting_activations: &mut conflict_cache::ConflictCache,
863+
parent: &Summary,
862864
dep: &Dependency,
863865
conflicting_activations: &ConflictMap,
864866
) -> Option<ConflictMap> {
@@ -873,6 +875,16 @@ fn generalize_conflicting(
873875
.unwrap();
874876
let jumpback_critical_reason: ConflictReason =
875877
conflicting_activations[&jumpback_critical_id].clone();
878+
879+
if cx
880+
.parents
881+
.is_path_from_to(&parent.package_id(), &jumpback_critical_id)
882+
{
883+
// We are a descendant of the trigger of the problem.
884+
// The best generalization of this is to let things bubble up
885+
// and let `jumpback_critical_id` figure this out.
886+
return None;
887+
}
876888
// What parents dose that critical activation have
877889
for (critical_parent, critical_parents_deps) in
878890
cx.parents.edges(&jumpback_critical_id).filter(|(p, _)| {

src/cargo/util/graph.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,24 @@ impl<N: Eq + Ord + Clone, E: Default + Clone> Graph<N, E> {
7171
self.nodes.keys()
7272
}
7373

74+
/// Checks if there is a path from `from` to `to`.
75+
pub fn is_path_from_to<'a>(&'a self, from: &'a N, to: &'a N) -> bool {
76+
let mut stack = vec![from];
77+
let mut seen = BTreeSet::new();
78+
seen.insert(from);
79+
while let Some(iter) = stack.pop().and_then(|p| self.nodes.get(p)) {
80+
for p in iter.keys() {
81+
if p == to {
82+
return true;
83+
}
84+
if seen.insert(p) {
85+
stack.push(p);
86+
}
87+
}
88+
}
89+
false
90+
}
91+
7492
/// Resolves one of the paths from the given dependent package down to
7593
/// a leaf.
7694
pub fn path_to_bottom<'a>(&'a self, mut pkg: &'a N) -> Vec<&'a N> {

0 commit comments

Comments
 (0)