Closed
Description
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
- git clone https://github.com/rillian/cargo-doc-example
- cd cargo-doc-example
- cargo run --example main
- 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]