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 --example doesn't provide dev-dependencies #10373

Closed
rillian opened this issue Feb 8, 2022 · 2 comments
Closed

cargo doc --example doesn't provide dev-dependencies #10373

rillian opened this issue Feb 8, 2022 · 2 comments
Labels
C-bug Category: bug

Comments

@rillian
Copy link
Contributor

rillian commented Feb 8, 2022

Problem

When building an example, cargo provides crates listed under both dependencies and dev-dependencies to the build. However cargo doc --example foo only passes the regular dependencies, resulting in unresolved import etc. errors for any symbols which aren't necessary for downstream use.

Steps

  1. git clone https://github.com/rillian/cargo-doc-example
  2. cd cargo-doc-example
  3. cargo run --example main
  4. cargo doc --example main
error[E0432]: unresolved import `env_logger`
 --> examples/main.rs:2:5
  |
2 | use env_logger::Env;
  |     ^^^^^^^^^^ use of undeclared crate or module `env_logger`

error: Compilation failed, aborting rustdoc

Possible Solution(s)

Probably the cargo doc command should receive the same dependency list as other subcommands under the --example or --examples switches.

Notes

cargo doc --example was added in #9808.

Version

cargo 1.58.0 (f01b232bc 2022-01-19)
release: 1.58.0
commit-hash: f01b232bc7f4d94f0c4603930a5a96277715eb8c
commit-date: 2022-01-19
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1l)
os: OracleLinux 35.0.0 [64-bit]
@rillian rillian added the C-bug Category: bug label Feb 8, 2022
@ehuss
Copy link
Contributor

ehuss commented Feb 8, 2022

Thanks for the detailed report! This has been fixed in #10341 which should be in the 1.60 release. It isn't in nightly, yet, but it should be in a few days.
Closing as a duplicate of #9198.

@ehuss ehuss closed this as completed Feb 8, 2022
@rillian
Copy link
Contributor Author

rillian commented Feb 8, 2022

Ha! thanks for the quick response!

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