Skip to content

Commit

Permalink
check is_public vs Kind more carefully
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Jun 20, 2019
1 parent 034c590 commit cb95f5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/cargo/core/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
16 changes: 4 additions & 12 deletions src/cargo/core/resolver/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cb95f5e

Please sign in to comment.