Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't clone a BacktrackFrame if we are not going to backtrack #5132

Merged
merged 1 commit into from
Mar 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions src/cargo/core/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,15 +892,19 @@ fn activate_deps_loop(
// We have a candidate. Clone a `BacktrackFrame`
// so we can add it to the `backtrack_stack` if activation succeeds.
// We clone now in case `activate` changes `cx` and then fails.
let backtrack = BacktrackFrame {
cur,
context_backup: Context::clone(&cx),
deps_backup: <BinaryHeap<DepsFrame>>::clone(&remaining_deps),
remaining_candidates: remaining_candidates.clone(),
parent: Summary::clone(&parent),
dep: Dependency::clone(&dep),
features: Rc::clone(&features),
conflicting_activations: conflicting_activations.clone(),
let backtrack = if has_another {
Some(BacktrackFrame {
cur,
context_backup: Context::clone(&cx),
deps_backup: <BinaryHeap<DepsFrame>>::clone(&remaining_deps),
remaining_candidates: remaining_candidates.clone(),
parent: Summary::clone(&parent),
dep: Dependency::clone(&dep),
features: Rc::clone(&features),
conflicting_activations: conflicting_activations.clone(),
})
} else {
None
};

let method = Method::Required {
Expand All @@ -925,12 +929,14 @@ fn activate_deps_loop(
// Add an entry to the `backtrack_stack` so
// we can try the next one if this one fails.
if successfully_activated {
if has_another {
backtrack_stack.push(backtrack);
if let Some(b) = backtrack {
backtrack_stack.push(b);
}
} else {
// `activate` changed `cx` and then failed so put things back.
cx = backtrack.context_backup;
if let Some(b) = backtrack {
// `activate` changed `cx` and then failed so put things back.
cx = b.context_backup;
} // else we are just using the cx for the error message so we can live with a corrupted one
}
}
}
Expand Down