Skip to content

Commit

Permalink
Auto merge of #11081 - WaffleLapkin:no_for_in_option, r=epage
Browse files Browse the repository at this point in the history
Don't use `for` loop on an `Option`

This PR removes a single `for` loop over `Option`, replacing it with an `if let` to improve code clarity. This currently blocks rust-lang/rust#99696 that adds a lint against this pattern.
  • Loading branch information
bors committed Sep 13, 2022
2 parents aa700d4 + d8f8e8f commit 0eac8be
Showing 1 changed file with 9 additions and 11 deletions.
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

0 comments on commit 0eac8be

Please sign in to comment.