diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 67b256eb999..25524fbbf3d 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -441,7 +441,12 @@ pub mod test { let overrides = self.query_overrides(dep); if overrides.is_empty() { - self.summaries.query(dep, f) + for s in self.summaries.iter() { + if dep.matches(s) { + f(s.clone()); + } + } + Ok(()) } else { for s in overrides { f(s); diff --git a/tests/resolve.rs b/tests/resolve.rs index 47b1e585b2b..042eda65dae 100644 --- a/tests/resolve.rs +++ b/tests/resolve.rs @@ -13,12 +13,26 @@ use cargo::core::{Dependency, PackageId, Summary, Registry}; use cargo::util::{CargoResult, ToUrl}; use cargo::core::resolver::{self, Method}; -fn resolve(pkg: PackageId, deps: Vec, - registry: &mut R) - -> CargoResult> { +fn resolve(pkg: PackageId, deps: Vec, registry: &[Summary]) + -> CargoResult> +{ + struct MyRegistry<'a>(&'a [Summary]); + impl<'a> Registry for MyRegistry<'a> { + fn query(&mut self, + dep: &Dependency, + f: &mut FnMut(Summary)) -> CargoResult<()> { + for summary in self.0.iter() { + if dep.matches(summary) { + f(summary.clone()); + } + } + Ok(()) + } + } + let mut registry = MyRegistry(registry); let summary = Summary::new(pkg.clone(), deps, HashMap::new()).unwrap(); let method = Method::Everything; - let resolve = resolver::resolve(&[(summary, method)], &[], registry)?; + let resolve = resolver::resolve(&[(summary, method)], &[], &mut registry)?; let res = resolve.iter().cloned().collect(); Ok(res) }