Skip to content

Commit

Permalink
remove Candidate.replace. Look it up if needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed May 15, 2019
1 parent 1b4fab3 commit c86b834
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
20 changes: 9 additions & 11 deletions src/cargo/core/resolver/dep_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct RegistryQueryer<'a> {
Rc<(HashSet<InternedString>, Rc<Vec<DepInfo>>)>,
>,
/// all the cases we ended up using a supplied replacement
used_replacements: HashMap<PackageId, PackageId>,
used_replacements: HashMap<PackageId, Summary>,
}

impl<'a> RegistryQueryer<'a> {
Expand All @@ -60,7 +60,11 @@ impl<'a> RegistryQueryer<'a> {
}

pub fn used_replacement_for(&self, p: PackageId) -> Option<(PackageId, PackageId)> {
self.used_replacements.get(&p).map(|&r| (p, r))
self.used_replacements.get(&p).map(|r| (p, r.package_id()))
}

pub fn replacement_summary(&self, p: PackageId) -> Option<&Summary> {
self.used_replacements.get(&p)
}

/// Queries the `registry` to return a list of candidates for `dep`.
Expand All @@ -78,10 +82,7 @@ impl<'a> RegistryQueryer<'a> {
self.registry.query(
dep,
&mut |s| {
ret.push(Candidate {
summary: s,
replace: None,
});
ret.push(Candidate { summary: s });
},
false,
)?;
Expand Down Expand Up @@ -157,12 +158,9 @@ impl<'a> RegistryQueryer<'a> {
for dep in summary.dependencies() {
debug!("\t{} => {}", dep.package_name(), dep.version_req());
}
if let Some(r) = &replace {
self.used_replacements
.insert(summary.package_id(), r.package_id());
if let Some(r) = replace {
self.used_replacements.insert(summary.package_id(), r);
}

candidate.replace = replace;
}

// When we attempt versions for a package we'll want to do so in a
Expand Down
5 changes: 2 additions & 3 deletions src/cargo/core/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ fn activate_deps_loop(
debug!("initial activation: {}", summary.package_id());
let candidate = Candidate {
summary: summary.clone(),
replace: None,
};
let res = activate(&mut cx, registry, None, candidate, method.clone());
match res {
Expand Down Expand Up @@ -659,7 +658,7 @@ fn activate(

let activated = cx.flag_activated(&candidate.summary, &method)?;

let candidate = match candidate.replace {
let candidate = match registry.replacement_summary(candidate_pid) {
Some(replace) => {
if cx.flag_activated(&replace, &method)? && activated {
return Ok(None);
Expand All @@ -669,7 +668,7 @@ fn activate(
replace.package_id(),
candidate_pid
);
replace
replace.clone()
}
None => {
if activated {
Expand Down
1 change: 0 additions & 1 deletion src/cargo/core/resolver/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ impl Method {
#[derive(Clone)]
pub struct Candidate {
pub summary: Summary,
pub replace: Option<Summary>,
}

#[derive(Clone)]
Expand Down

0 comments on commit c86b834

Please sign in to comment.