Skip to content

Commit

Permalink
Inline implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita240 committed Mar 5, 2024
1 parent 19141bd commit c495b15
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions src/cargo/core/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,6 @@ fn activate_deps_loop(
.conflicting(&resolver_ctx, &dep)
.is_some();

let mut remaining_candidates = RemainingCandidates::new(&candidates);

// `conflicting_activations` stores all the reasons we were unable to
// activate candidates. One of these reasons will have to go away for
// backtracking to find a place to restart. It is also the list of
Expand All @@ -271,6 +269,45 @@ fn activate_deps_loop(
// conflict for us.
let mut conflicting_activations = ConflictMap::new();

let mut activated_candidates: Vec<Summary> = Vec::with_capacity(candidates.len());
let mut prioritized_candidates: Vec<Summary> = Vec::with_capacity(candidates.len());

for b in candidates.as_ref() {
let b_id = b.package_id();

// The `links` key in the manifest dictates that there's only one
// package in a dependency graph, globally, with that particular
// `links` key. If this candidate links to something that's already
// linked to by a different package then we've gotta skip this.
if let Some(link) = b.links() {
if let Some(&a) = resolver_ctx.links.get(&link) {
if a != b_id {
// prioritized_candidates.push(b.clone());
conflicting_activations
.entry(a)
.or_insert_with(|| ConflictReason::Links(link));
continue;
}
}
}

if let Some((a, _)) = resolver_ctx.activations.get(&b_id.as_activations_key()) {
if a == b {
activated_candidates.push(b.clone());
} else {
prioritized_candidates.push(b.clone());
}
} else {
prioritized_candidates.push(b.clone());
}
}

let remaining_candidates = activated_candidates
.into_iter()
.chain(prioritized_candidates.into_iter())
.collect();
let mut remaining_candidates = RemainingCandidates::new(&Rc::new(remaining_candidates));

// When backtracking we don't fully update `conflicting_activations`
// especially for the cases that we didn't make a backtrack frame in the
// first place. This `backtracked` var stores whether we are continuing
Expand Down Expand Up @@ -752,6 +789,9 @@ impl RemainingCandidates {
conflicting_prev_active: &mut ConflictMap,
cx: &ResolverContext,
) -> Option<(Summary, bool)> {
// for remainer in self.remaining.by_ref() {
// dbg!(&remainer);
// }
for b in self.remaining.by_ref() {
let b_id = b.package_id();
// The `links` key in the manifest dictates that there's only one
Expand Down

0 comments on commit c495b15

Please sign in to comment.