-
Notifications
You must be signed in to change notification settings - Fork 13.3k
unclear behaviour of missing_doc_code_examples #60664
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
Comments
it does not work as expected right now (cf rust-lang/rust#60664)
For |
Fix lints handling in rustdoc Part of rust-lang#60664: now lints are handled just like any other lints you would setup in rustc. Still remains to handle `missing code examples` and `missing_docs` as part of the same group. r? @oli-obk
I feel like the title of this issue is slightly misleading. The behaviour is not simply unclear, it's totally broken. |
@danieleades The situation should have been improved since then. Do you still have a good example of where it's totally broken so we can continue to improve the whole situation? |
yep. steps to reproduce-
#![deny(missing_doc_code_examples)]
/// this function has no code examples
pub fn some_function() {}
rust: 1.49.0-nightly |
It works as expected for me: $ rustdoc --version
rustdoc 1.49.0-nightly (ffa2e7ae8 2020-10-24)
$ rustdoc foo.rs
error: missing code example in this documentation
--> foo.rs:1:1
|
1 | / #![deny(missing_doc_code_examples)]
2 | |
3 | | /// this function has no code examples
4 | | pub fn some_function() {}
| |_________________________^
|
note: the lint level is defined here
--> foo.rs:1:9
|
1 | #![deny(missing_doc_code_examples)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: missing code example in this documentation
--> foo.rs:3:1
|
3 | /// this function has no code examples
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors |
presumably that's because you didn't follow my reproduction steps. Is it the intended behaviour that this lint only fire if you're building documentation with rustdoc? If so, that's inconsistent with all the other lints |
It's only supposed to be triggered by rustdoc indeed (my bad, didn't see you didn't use the |
hmm i see after some digging that it's marked as 'rustdoc only' here - https://doc.rust-lang.org/beta/rustc/lints/listing/allowed-by-default.html#missing-doc-code-examples. Mea culpa. Perhaps there are good historical or technical reasons why this is the case, but while i'm glad it's documented, simply describing the behaviour doesn't make it consistent. this is inconsistent in the sense that out of ~120 or so rustc lints, there are how many that are 'rustdoc-only'? 2-3? Given that the current behaviour is documented (though unexpected) I'm now in complete support of the issue title ;) |
You can see the list of the rustdoc lints there: rust/compiler/rustc_lint/src/lib.rs Lines 314 to 322 in 0d033de
|
Seems like this issue was fixed so closing. Don't hesitate to reopen if something is still missing. |
Hello,
consider this code example:
Here I would expect the following behaviour when running
cargo doc
:module1
hasallow(missing_docs)
somissing_doc_code_examples
should be silentmodule2
hasallow(missing_doc_code_examples)
yet we still get errors for missing docs onmodule2
, I think we should notmodule3
has a code example, butmodule3::test
does not, we should get an error for the missing example onmodule3::test
cc @GuillaumeGomez
The text was updated successfully, but these errors were encountered: