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

Nits: Remove unneeded mut and loop #8334

Merged
merged 1 commit into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions src/cargo/core/resolver/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@ impl Resolve {

pub fn register_used_patches(&mut self, patches: &[Summary]) {
for summary in patches {
if self.iter().any(|id| id == summary.package_id()) {
continue;
}
self.unused_patches.push(summary.package_id());
if !self.graph.contains(&summary.package_id()) {
self.unused_patches.push(summary.package_id())
};
}
}

Expand Down
36 changes: 20 additions & 16 deletions src/cargo/ops/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,14 @@ pub fn resolve_with_previous<'cfg>(
//
// TODO: this seems like a hokey reason to single out the registry as being
// different.
let mut to_avoid_sources: HashSet<SourceId> = HashSet::new();
if let Some(to_avoid) = to_avoid {
to_avoid_sources.extend(
to_avoid
.iter()
let to_avoid_sources: HashSet<SourceId> = to_avoid
.map(|set| {
set.iter()
.map(|p| p.source_id())
.filter(|s| !s.is_registry()),
);
}
.filter(|s| !s.is_registry())
.collect()
})
.unwrap_or_default();

let pre_patch_keep = |p: &PackageId| {
!to_avoid_sources.contains(&p.source_id())
Expand Down Expand Up @@ -286,18 +285,23 @@ pub fn resolve_with_previous<'cfg>(
// 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.
let mut try_to_use = HashSet::new();
if let Some(r) = previous {
trace!("previous: {:?}", r);
register_previous_locks(ws, registry, r, &keep);

// Everything in the previous lock file we want to keep is prioritized
// in dependency selection if it comes up, aka we want to have
// conservative updates.
try_to_use.extend(r.iter().filter(keep).inspect(|id| {
debug!("attempting to prefer {}", id);
}));
}
// Everything in the previous lock file we want to keep is prioritized
// in dependency selection if it comes up, aka we want to have
// conservative updates.
let try_to_use = previous
.map(|r| {
r.iter()
.filter(keep)
.inspect(|id| {
debug!("attempting to prefer {}", id);
})
.collect()
})
.unwrap_or_default();

if register_patches {
registry.lock_patches();
Expand Down