Skip to content

Commit b850c25

Browse files
committed
Collect library/binary names when documenting even if a spec was given
This seems more consistent and generally should work better.
1 parent 9576b31 commit b850c25

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/cargo/ops/cargo_doc.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,19 @@ pub fn doc(ws: &Workspace, options: &DocOptions) -> CargoResult<()> {
3434

3535
let mut lib_names = HashSet::new();
3636
let mut bin_names = HashSet::new();
37-
if specs.is_empty() {
38-
for package in &pkgs {
39-
for target in package.targets().iter().filter(|t| t.documented()) {
40-
if target.is_lib() {
41-
assert!(lib_names.insert(target.crate_name()));
42-
} else {
43-
assert!(bin_names.insert(target.crate_name()));
44-
}
37+
for package in &pkgs {
38+
for target in package.targets().iter().filter(|t| t.documented()) {
39+
if target.is_lib() {
40+
assert!(lib_names.insert(target.crate_name()));
41+
} else {
42+
assert!(bin_names.insert(target.crate_name()));
4543
}
46-
for bin in bin_names.iter() {
47-
if lib_names.contains(bin) {
48-
bail!("cannot document a package where a library and a binary \
49-
have the same name. Consider renaming one or marking \
50-
the target as `doc = false`")
51-
}
44+
}
45+
for bin in bin_names.iter() {
46+
if lib_names.contains(bin) {
47+
bail!("cannot document a package where a library and a binary \
48+
have the same name. Consider renaming one or marking \
49+
the target as `doc = false`")
5250
}
5351
}
5452
}

0 commit comments

Comments
 (0)