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 use for loop on an Option #11081

Merged
merged 1 commit into from
Sep 13, 2022
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
20 changes: 9 additions & 11 deletions src/cargo/ops/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,21 +386,19 @@ pub fn resolve_with_previous<'cfg>(
let keep = |p: &PackageId| pre_patch_keep(p) && !avoid_patch_ids.contains(p);

let dev_deps = ws.require_optional_deps() || has_dev_units == HasDevUnits::Yes;
// In the case where a previous instance of resolve is available, we
// want to lock as many packages as possible to the previous version
// without disturbing the graph structure.

if let Some(r) = previous {
trace!("previous: {:?}", r);

// In the case where a previous instance of resolve is available, we
// want to lock as many packages as possible to the previous version
// without disturbing the graph structure.
register_previous_locks(ws, registry, r, &keep, dev_deps);
}

// Prefer to use anything in the previous lock file, aka we want to have conservative updates.
for r in previous {
for id in r.iter() {
if keep(&id) {
debug!("attempting to prefer {}", id);
version_prefs.prefer_package_id(id);
}
// Prefer to use anything in the previous lock file, aka we want to have conservative updates.
for id in r.iter().filter(keep) {
debug!("attempting to prefer {}", id);
version_prefs.prefer_package_id(id);
}
}

Expand Down