Skip to content

cargo doc fails for bin+lib projects with - in the name #13628

@MaxVerevkin

Description

@MaxVerevkin

Problem

A project with both binary and library targets and with "-" in the name causes cargo doc to print a huge warning. Current stable version (1.77) works and documents the library. Current nightly (cargo 1.79.0-nightly (d438c80 2024-03-19) documents the binary.

Projects without "-" in their name are not affected.

sh-5.2$ ls src
lib.rs	main.rs
sh-5.2$ cargo +stable doc
 Documenting test-proj v0.1.0 (/tmp/testproj)
    Finished dev [unoptimized + debuginfo] target(s) in 0.25s
   Generated /tmp/testproj/target/doc/test_proj/index.html
sh-5.2$ cargo +nightly doc
warning: output filename collision.
The bin target `test-proj` in package `test-proj v0.1.0 (/tmp/testproj)` has the same output filename as the lib target `test_proj` in package `test-proj v0.1.0 (/tmp/testproj)`.
Colliding filename is: /tmp/testproj/target/doc/test_proj/index.html
The output filenames should be unique.
This is a known bug where multiple crates with the same name use
the same path; see <https://github.com/rust-lang/cargo/issues/6313>.
If this looks unexpected, it may be a bug in Cargo. Please file a bug report at
https://github.com/rust-lang/cargo/issues/ with as much information as you
can provide.
cargo 1.79.0-nightly (d438c80c4 2024-03-19) running on `x86_64-unknown-linux-gnu` target `x86_64-unknown-linux-gnu`
First unit: Unit { pkg: Package { id: PackageId { name: "test-proj", version: "0.1.0", source: "/tmp/testproj" }, ..: ".." }, target: TargetInner { name: "test-proj", doc: true, ..: with_path("/tmp/testproj/src/main.rs", Edition2021) }, profile: Profile { ..: default_dev() }, kind: Host, mode: Doc { deps: true, json: false }, features: [], artifact: false, artifact_target_for_features: None, is_std: false, dep_hash: 3508259363715858619 }
Second unit: Unit { pkg: Package { id: PackageId { name: "test-proj", version: "0.1.0", source: "/tmp/testproj" }, ..: ".." }, target: TargetInner { name_inferred: true, ..: lib_target("test_proj", ["lib"], "/tmp/testproj/src/lib.rs", Edition2021) }, profile: Profile { ..: default_dev() }, kind: Host, mode: Doc { deps: true, json: false }, features: [], artifact: false, artifact_target_for_features: None, is_std: false, dep_hash: 2202906307356721367 }
 Documenting test-proj v0.1.0 (/tmp/testproj)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.52s
   Generated /tmp/testproj/target/doc/test_proj/index.html and 1 other file

Steps

No response

Possible Solution(s)

No response

Notes

No response

Version

No response

Metadata

Metadata

Assignees

Labels

C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions