Skip to content

Conversation

@phy1729
Copy link

@phy1729 phy1729 commented Nov 26, 2025

Add missing_examples_doc lint to check that non-hidden public functions have an # Examples header in their doc comment.

changelog: Added [`missing_examples_doc`] to `pedantic`

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. lintcheck shows there would be over 1500 new lint instances. I put the lint in pedantic to match missing_{errors,panic}_doc; but due to how many times the lint triggers currently, perhaps it should go into nursery or restriction?

Couldn't think of a good example for the lint, so what is there is eminently bikesheddable (yes, I do see the irony).

@rustbot
Copy link
Collaborator

rustbot commented Nov 26, 2025

Some changes occurred in clippy_lints/src/doc

cc @notriddle

@rustbot rustbot added needs-fcp S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Nov 26, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 26, 2025

r? @samueltardieu

rustbot has assigned @samueltardieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@github-actions
Copy link

github-actions bot commented Nov 26, 2025

Lintcheck changes for 0ac23b7

Lint Added Removed Changed
clippy::missing_examples_doc 13291 0 0

This comment will be updated if you push new changes

@phy1729 phy1729 force-pushed the missing_examples_doc branch from cee1293 to 0ac23b7 Compare November 26, 2025 16:05
/// "blue"
/// }
/// ```
#[clippy::version = "1.92.0"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[clippy::version = "1.92.0"]
#[clippy::version = "1.93.0"]

Comment on lines +1309 to +1315
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";
Copy link
Member

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,}
}

Comment on lines +92 to +93
"-A",
"clippy::missing_examples_doc",
Copy link
Member

@samueltardieu samueltardieu Nov 26, 2025

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,
Copy link
Member

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.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Nov 26, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 26, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@samueltardieu
Copy link
Member

FCP opened on Zulip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-fcp S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants