mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
reorganize the loop
This commit is contained in:
parent
a9da3c8345
commit
8014091612
@ -958,13 +958,14 @@ fn find_candidate(
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let mut new_frame = None;
|
||||
if let Some(age) = age {
|
||||
while let Some(frame) = backtrack_stack.pop() {
|
||||
// If all members of `conflicting_activations` are still
|
||||
// active in this back up we know that we're guaranteed to not actually
|
||||
// make any progress. As a result if we hit this condition we can
|
||||
// completely skip this backtrack frame and move on to the next.
|
||||
|
||||
while let Some(mut frame) = backtrack_stack.pop() {
|
||||
// If all members of `conflicting_activations` are still
|
||||
// active in this back up we know that we're guaranteed to not actually
|
||||
// make any progress. As a result if we hit this condition we can
|
||||
// completely skip this backtrack frame and move on to the next.
|
||||
if let Some(age) = age {
|
||||
// Above we use `cx` to determine if this is going to be conflicting.
|
||||
// But lets just double check if the `pop`ed frame agrees.
|
||||
let frame_too_new = frame.context.age >= age;
|
||||
@ -975,26 +976,30 @@ fn find_candidate(
|
||||
== frame_too_new.then_some(age)
|
||||
);
|
||||
|
||||
if frame_to_new {
|
||||
trace!(
|
||||
"{} = \"{}\" skip as not solving {}: {:?}",
|
||||
frame.dep.package_name(),
|
||||
frame.dep.version_req(),
|
||||
parent.package_id(),
|
||||
conflicting_activations
|
||||
);
|
||||
continue;
|
||||
if !frame_too_new {
|
||||
new_frame = Some(frame);
|
||||
break;
|
||||
}
|
||||
trace!(
|
||||
"{} = \"{}\" skip as not solving {}: {:?}",
|
||||
frame.dep.package_name(),
|
||||
frame.dep.version_req(),
|
||||
parent.package_id(),
|
||||
conflicting_activations
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// If we're here then we are in abnormal situations and need to just go one frame at a time.
|
||||
new_frame = backtrack_stack.pop();
|
||||
}
|
||||
|
||||
new_frame.map(|mut frame| {
|
||||
let (candidate, has_another) = frame
|
||||
.remaining_candidates
|
||||
.next(&mut frame.conflicting_activations, &frame.context)
|
||||
.expect("why did we save a frame that has no next?");
|
||||
|
||||
return Some((candidate, has_another, frame));
|
||||
}
|
||||
None
|
||||
(candidate, has_another, frame)
|
||||
})
|
||||
}
|
||||
|
||||
fn check_cycles(resolve: &Resolve) -> CargoResult<()> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user