Skip to content
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

cargo doc fails to build documentation for binary crate dependencies #10723

Closed
sh34v3 opened this issue Jun 2, 2022 · 3 comments
Closed

cargo doc fails to build documentation for binary crate dependencies #10723

sh34v3 opened this issue Jun 2, 2022 · 3 comments
Labels
C-bug Category: bug

Comments

@sh34v3
Copy link

sh34v3 commented Jun 2, 2022

Problem

Learning to use rust via:

Source: The Rust Programming Language
Author: Steve Klabnik, Carol Nichols
ISBN: 978-1-7185-0044-0
Date: 2018

According to page 20, cargo doc --open should build a documentation for the current binary project along with documentation for its dependencies. Currently, despite dependencies properly registered in Cargo.toml, the dependency documentation is not built and must be built manually via cargo doc -p $(cargo pkgid rand:0.3.23)

Steps

  1. cargo new guessing_game
  2. add rand = "0.3.23" to [dependencies] in Cargo.toml
  3. inside /src/main.rs, place use rand::Rng; at the top of the file
  4. change to project directory
  5. cargo build
  6. cargo doc --open
  7. notice the rand documentation is not included
  8. cargo doc -p $(cargo pkgid rand:0.3.23)
  9. cargo doc --open
  10. notice the rand documentation now is included

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.61.0 (a028ae4 2022-04-29)
release: 1.61.0
commit-hash: a028ae42fc1376571de836be702e840ca8e060c2
commit-date: 2022-04-29
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1m)
os: Ubuntu 21.10 (impish) [64-bit]

Cargo.toml.txt
Cargo.lock.txt

@sh34v3 sh34v3 added the C-bug Category: bug label Jun 2, 2022
@ehuss
Copy link
Contributor

ehuss commented Jun 2, 2022

Thanks for the detailed report! This is a known issue where if there are two crates with the same name, where one depends on the other, it ends up not documenting either (called the "semver trick"). Unfortunately the fix might be somewhat difficult or tricky. Closing as a duplicate of #10241.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Jun 2, 2022
@sh34v3
Copy link
Author

sh34v3 commented Jun 2, 2022

For the sake of clarity, please tell me if my understanding is correct. I see in Cargo.lock that rand v0.3.23 depends on other versions of rand (v0.4.x). Because rand depends on rand, the documentation of rand will not be built with cargo doc?

@ehuss
Copy link
Contributor

ehuss commented Jun 2, 2022

That's correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants