check is_public vs Kind more carefully

This commit is contained in:
Eh2406 2019-06-20 13:58:51 -04:00
parent 034c5908d8
commit cb95f5ef7c
2 changed files with 8 additions and 12 deletions

View File

@ -328,6 +328,10 @@ impl Dependency {
}
pub fn set_kind(&mut self, kind: Kind) -> &mut Dependency {
if self.is_public() {
// Setting 'public' only makes sense for normal dependencies
assert_eq!(kind, Kind::Normal);
}
Rc::make_mut(&mut self.inner).kind = kind;
self
}

View File

@ -49,19 +49,11 @@ impl Resolve {
.map(|p| {
let public_deps = graph
.edges(p)
.flat_map(|(dep_package, deps)| {
let id_opt: Option<PackageId> = deps
.iter()
.find(|d| d.kind() == Kind::Normal)
.and_then(|d| {
if d.is_public() {
Some(*dep_package)
} else {
None
}
});
id_opt
.filter(|(_, deps)| {
deps.iter()
.any(|d| d.kind() == Kind::Normal && d.is_public())
})
.map(|(dep_package, _)| *dep_package)
.collect::<HashSet<PackageId>>();
(*p, public_deps)