Skip to content

Commit 0eac8be

Browse files
committed
Auto merge of #11081 - WaffleLapkin:no_for_in_option, r=epage
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.
2 parents aa700d4 + d8f8e8f commit 0eac8be

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/cargo/ops/resolve.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -386,21 +386,19 @@ pub fn resolve_with_previous<'cfg>(
386386
let keep = |p: &PackageId| pre_patch_keep(p) && !avoid_patch_ids.contains(p);
387387

388388
let dev_deps = ws.require_optional_deps() || has_dev_units == HasDevUnits::Yes;
389-
// In the case where a previous instance of resolve is available, we
390-
// want to lock as many packages as possible to the previous version
391-
// without disturbing the graph structure.
389+
392390
if let Some(r) = previous {
393391
trace!("previous: {:?}", r);
392+
393+
// In the case where a previous instance of resolve is available, we
394+
// want to lock as many packages as possible to the previous version
395+
// without disturbing the graph structure.
394396
register_previous_locks(ws, registry, r, &keep, dev_deps);
395-
}
396397

397-
// Prefer to use anything in the previous lock file, aka we want to have conservative updates.
398-
for r in previous {
399-
for id in r.iter() {
400-
if keep(&id) {
401-
debug!("attempting to prefer {}", id);
402-
version_prefs.prefer_package_id(id);
403-
}
398+
// Prefer to use anything in the previous lock file, aka we want to have conservative updates.
399+
for id in r.iter().filter(keep) {
400+
debug!("attempting to prefer {}", id);
401+
version_prefs.prefer_package_id(id);
404402
}
405403
}
406404

0 commit comments

Comments
 (0)