Skip to content

cargo doc breaks links to dependencies with the same name but different versions #15299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ianrrees opened this issue Mar 12, 2025 · 1 comment
Labels
C-bug Category: bug Command-doc S-triage Status: This issue is waiting on initial triage.

Comments

@ianrrees
Copy link
Contributor

Problem

When a crate depends on different versions of another crate, cargo doc documents only one version of the dependency. This makes it impossible for docstrings to link to other versions of the dependency, and leads to #6313 .

I've uploaded a repo with a minimal reproduction: https://github.com/ianrrees/cargo-doc-bug

Steps

  1. Clone https://github.com/ianrrees/cargo-doc-bug
  2. cd in to the myapp directory, cargo doc --open
  3. Note that there are links to both v1 and v2 of mylib, however the link to mylib_1::divide actually goes to documentation for v2.

Possible Solution(s)

It appears that cargo doc generates documentation for each crate under a subdirectory simply based on the crate name, perhaps adding a layer of directories for the version could both resolve this issue, and prevent duplicate documentation from being generated.

Notes

No response

Version

cargo 1.85.0 (d73d2caf9 2024-12-31)
release: 1.85.0
commit-hash: d73d2caf9e41a39daf2a8d6ce60ec80bf354d2a7
commit-date: 2024-12-31
host: x86_64-unknown-linux-gnu
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Ubuntu 24.4.0 (noble) [64-bit]
@ianrrees ianrrees added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Mar 12, 2025
@weihanglo
Copy link
Member

Cargo doc checks duplicates at workspace member level but is not able to do that for dependencies. This is currently blocked on #10241, which essentially needs support from rustdoc.

See also:

Close as duplicate of #10241. Thanks for the issue report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug Command-doc S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants