-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Rustdoc shouldn't lint about missing code examples in derived traits #81775
Comments
searched nightlies: from nightly-2020-09-30 to nightly-2020-11-30 bisected with cargo-bisect-rustc v0.6.0Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc 2020-09-30 --end=2020-11-30 --script=./test.sh --access=github so probably #78908? |
What is the correct option here ? Ignoring derived traits or putting default examples on the derive for those types ? The first seems hard to do but I'm maybe missing knowledge to see it done. The second means the examples won't be very relevant to the type on which they are derived. For |
I think rustdoc shouldn't require examples for derived traits. rust/src/librustdoc/passes/doc_test_lints.rs Lines 77 to 80 in f9435f4
A possible fix is to only call |
Don't lint about missing code examples in derived traits When the `missing_doc_code_examples` lint is performed it also requires that derived Trait implementations have a code example for each member etc., which causes undesirable behavior. # Examples With `missing_doc_code_examples` enable we are not able to use the `Clone` derive macro due to the generated code not being documented: ```rust #[deny(rustdoc::missing_doc_code_examples)] /// docs /// ``` /// let s = SomeStruct; /// ``` #[derive(Clone)] pub struct SomeStruct; ``` yields: ``` Documenting testt v0.1.0 (<redacted>) error: missing code example in this documentation --> src/lib.rs:7:10 | 7 | #[derive(Clone)] | ^^^^^ | note: the lint level is defined here --> src/lib.rs:1:8 | 1 | #[deny(rustdoc::missing_doc_code_examples)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing code example in this documentation --> src/lib.rs:7:10 | 7 | #[derive(Clone)] | ^^^^^ error: could not document `testt` Caused by: process didn't exit successfully: `rustdoc ... ``` closes rust-lang#81775
I tried this code:
I expected to see this happen:
cargo doc
succeeds.Instead, this happened:
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: