-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add missing_examples_doc lint #16143
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
base: master
Are you sure you want to change the base?
Conversation
|
Some changes occurred in clippy_lints/src/doc cc @notriddle |
|
rustbot has assigned @samueltardieu. Use |
|
Lintcheck changes for 0ac23b7
This comment will be updated if you push new changes |
cee1293 to
0ac23b7
Compare
| /// "blue" | ||
| /// } | ||
| /// ``` | ||
| #[clippy::version = "1.92.0"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #[clippy::version = "1.92.0"] | |
| #[clippy::version = "1.93.0"] |
| headers.safety |= in_heading && trimmed_text == "Safety"; | ||
| headers.safety |= in_heading && trimmed_text == "SAFETY"; | ||
| headers.safety |= in_heading && trimmed_text == "Implementation safety"; | ||
| headers.safety |= in_heading && trimmed_text == "Implementation Safety"; | ||
| headers.errors |= in_heading && trimmed_text == "Errors"; | ||
| headers.panics |= in_heading && trimmed_text == "Panics"; | ||
| headers.examples |= in_heading && trimmed_text == "Examples"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is starting to becoming a long list of repetition. It would probably better to have something like:
if in_heading {
match trimmed_text {
"Safety" | "SAFETY" | … => headers.safety = true,
…
}
}| "-A", | ||
| "clippy::missing_examples_doc", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we want to activate such a lint by default anyway, it might cause problems for modifications done in the Rust repository. When it becomes a restriction lint, this part can be removed.
| /// ``` | ||
| #[clippy::version = "1.92.0"] | ||
| pub MISSING_EXAMPLES_DOC, | ||
| pedantic, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is a bit too opinionated for pedantic, restriction would be better.
|
Reminder, once the PR becomes ready for a review, use |
Add
missing_examples_doclint to check that non-hidden public functions have an# Examplesheader in their doc comment.The Rust API Guidelines suggest that all items have a rustdoc example.
I modified the dogfood test to allow this lint since otherwise the test fails with over 500 errors.
lintcheckshows there would be over 1500 new lint instances. I put the lint in pedantic to matchmissing_{errors,panic}_doc; but due to how many times the lint triggers currently, perhaps it should go intonurseryorrestriction?Couldn't think of a good example for the lint, so what is there is eminently bikesheddable (yes, I do see the irony).