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 --examples ignores dev dependencies #10318

Closed
asomers opened this issue Jan 22, 2022 · 3 comments · Fixed by #10341
Closed

cargo doc --examples ignores dev dependencies #10318

asomers opened this issue Jan 22, 2022 · 3 comments · Fixed by #10341
Assignees
Labels
A-examples Area: example targets C-bug Category: bug Command-doc E-easy Experience: Easy

Comments

@asomers
Copy link

asomers commented Jan 22, 2022

Problem

With --examples, cargo doc is supposed to document your examples too. However, the examples may need dev dependencies in order to compile, and cargo doc does not include those, leading to errors about unresolved imports.

Steps

  1. git clone git@github.com:asomers/mockall.git
  2. cd mockall
  3. cargo doc --examples
...
error[E0432]: unresolved import `mockall_double`
 --> mockall/examples/ffi.rs:8:5
  |
8 | use mockall_double::double;
  |     ^^^^^^^^^^^^^^ use of undeclared crate or module `mockall_double`
  |
help: there is a crate or module with a similar name
  |
8 | use mockall_derive::double;
  |     ~~~~~~~~~~~~~~
...

Possible Solution(s)

cargo doc --examples should resolve dev-dependencies, just like cargo check --examples does.

Notes

No response

Version

> cargo version --verbose
cargo 1.60.0-nightly (95bb3c92b 2022-01-18)
release: 1.60.0-nightly
commit-hash: 95bb3c92bf516017e812e7f1c14c2dea3845b30e
commit-date: 2022-01-18
host: x86_64-unknown-freebsd
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: FreeBSD 14.0-CURRENT [64-bit]
@asomers asomers added the C-bug Category: bug label Jan 22, 2022
@ehuss
Copy link
Contributor

ehuss commented Jan 24, 2022

For fixing: This line needs to consider other dependency kinds based on the target type. Here is how it is done for regular builds. Perhaps those can be shared?

@ehuss ehuss added A-examples Area: example targets Command-doc E-easy Experience: Easy labels Jan 24, 2022
@Rustin170506
Copy link
Member

@rustbot claim

@jyn514
Copy link
Member

jyn514 commented Jan 26, 2022

Duplicate of #9198.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-examples Area: example targets C-bug Category: bug Command-doc E-easy Experience: Easy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants