Skip to content

Commit cb95f5e

Browse files
committed
check is_public vs Kind more carefully
1 parent 034c590 commit cb95f5e

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/cargo/core/dependency.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ impl Dependency {
328328
}
329329

330330
pub fn set_kind(&mut self, kind: Kind) -> &mut Dependency {
331+
if self.is_public() {
332+
// Setting 'public' only makes sense for normal dependencies
333+
assert_eq!(kind, Kind::Normal);
334+
}
331335
Rc::make_mut(&mut self.inner).kind = kind;
332336
self
333337
}

src/cargo/core/resolver/resolve.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,11 @@ impl Resolve {
4949
.map(|p| {
5050
let public_deps = graph
5151
.edges(p)
52-
.flat_map(|(dep_package, deps)| {
53-
let id_opt: Option<PackageId> = deps
54-
.iter()
55-
.find(|d| d.kind() == Kind::Normal)
56-
.and_then(|d| {
57-
if d.is_public() {
58-
Some(*dep_package)
59-
} else {
60-
None
61-
}
62-
});
63-
id_opt
52+
.filter(|(_, deps)| {
53+
deps.iter()
54+
.any(|d| d.kind() == Kind::Normal && d.is_public())
6455
})
56+
.map(|(dep_package, _)| *dep_package)
6557
.collect::<HashSet<PackageId>>();
6658

6759
(*p, public_deps)

0 commit comments

Comments
 (0)