rust/tests/ui/doc
Alex Macleod 86e036af36
Add a doc_paragraphs_missing_punctuation lint (#15758)
This introduces a new lint that aims to check for missing terminal
punctuation in doc comments.

## Lint scope and motivation

It partially addresses
https://github.com/rust-lang/rust-clippy/issues/8371 by currently
focusing on the case that is both the easiest to look for without
advanced NLP capacities and still very useful: missing punctuation at
the end of the last sentence of doc comments. This is particularly
useful when working in a team to enforce a style guide and make sure all
doc comments end with some kind of punctuation, which is often forgotten
in the case of short, single-sentence doc comments. The lint is biased
towards avoiding false positives so it can be easily adopted without
requiring an excessive number of `#[expect]` attributes.

It is currently only concerned with Latin languages, but adding support
for `。` for instance should be very easy.

Even if consistently ending doc comments (even very short ones) with
punctuation is somewhat of an opinion, it seems sufficiently
well-established, [at least in the
`std`](https://github.com/rust-lang/rust/pull/91886), to warrant its own
lint, even if of course it would be allow-by-default.

## Lint category and possible evolution

Because it is unclear how useful and more complex it would be to also
look for missing punctuation at the end of *each* Markdown paragraphs, I
opted for the `nursery` category for now. My understanding of [the
stability
guarantees](https://github.com/rust-lang/rfcs/blob/master/text/2476-clippy-uno.md#stability-guarantees)
is that would it not be acceptable to add such capability later if it
was part of `pedantic` or `restriction` categories right away. I tried
to make sure the lint name allows this kind of iterative evolution.

## Testing

I ran the lint against the `core` library which led me to introduce a
few special cases (which seem common enough) to avoid false positives:
e.g., the last sentence being in parentheses. After excluding specific
modules which should likely be excluded (e.g., `core_arch`,
`intrinsincs`), it currently finds a bit more than 200 errors in the
`core` library.

This lint also helped find issues with a few doc comments, which [are
now fixed](https://github.com/rust-lang/rust/pull/146136).

## How to review this PR

I suppose it is easier to have a look at the UI tests first before
checking the implementation.

---

*Please write a short comment explaining your change (or "none" for
internal only changes)*

changelog: add new lint [`doc_paragraphs_missing_punctuation`]
2025-11-15 14:56:50 +00:00
..
doc-fixable.fixed doc_markdown: add InfiniBand and RoCE to whitelist 2025-08-26 06:13:26 +08:00
doc-fixable.rs doc_markdown: add InfiniBand and RoCE to whitelist 2025-08-26 06:13:26 +08:00
doc-fixable.stderr doc_markdown: add InfiniBand and RoCE to whitelist 2025-08-26 06:13:26 +08:00
doc_comment_double_space_linebreaks.fixed doc_comment_double_space_linebreaks: Fix tests 2025-03-01 12:15:24 +01:00
doc_comment_double_space_linebreaks.rs doc_comment_double_space_linebreaks: Fix tests 2025-03-01 12:15:24 +01:00
doc_comment_double_space_linebreaks.stderr doc_comment_double_space_linebreaks: Fix tests 2025-03-01 12:15:24 +01:00
doc_include_without_cfg.fixed Update UI tests 2025-02-15 13:38:16 +01:00
doc_include_without_cfg.rs Update UI tests 2025-02-15 13:38:16 +01:00
doc_include_without_cfg.stderr Update UI tests 2025-02-15 13:38:16 +01:00
doc_lazy_blockquote.fixed Merge commit 'b794b8e08c' into clippy-subtree-update 2024-07-11 15:44:03 +02:00
doc_lazy_blockquote.rs Merge commit 'b794b8e08c' into clippy-subtree-update 2024-07-11 15:44:03 +02:00
doc_lazy_blockquote.stderr Merge commit 'b794b8e08c' into clippy-subtree-update 2024-07-11 15:44:03 +02:00
doc_lazy_list.fixed Merge commit '51d49c1ae2' into clippy-subtree-update 2025-01-28 19:33:54 +01:00
doc_lazy_list.rs Merge commit '51d49c1ae2' into clippy-subtree-update 2025-01-28 19:33:54 +01:00
doc_lazy_list.stderr Merge commit '51d49c1ae2' into clippy-subtree-update 2025-01-28 19:33:54 +01:00
doc_markdown-issue_13097.fixed Review comments & Add testing 2025-05-21 23:44:28 +02:00
doc_markdown-issue_13097.rs Review comments & Add testing 2025-05-21 23:44:28 +02:00
doc_markdown-issue_13097.stderr Review comments & Add testing 2025-05-21 23:44:28 +02:00
doc_nested_refdef_blockquote.fixed Merge commit '609cd310be' into clippy-subtree-update 2024-12-26 15:15:54 +01:00
doc_nested_refdef_blockquote.rs Merge commit '609cd310be' into clippy-subtree-update 2024-12-26 15:15:54 +01:00
doc_nested_refdef_blockquote.stderr Merge commit '609cd310be' into clippy-subtree-update 2024-12-26 15:15:54 +01:00
doc_nested_refdef_list_item.fixed doc_nested_refdefs: do not falsely report checkboxes as refdefs 2025-06-26 09:19:59 -07:00
doc_nested_refdef_list_item.rs doc_nested_refdefs: do not falsely report checkboxes as refdefs 2025-06-26 09:19:59 -07:00
doc_nested_refdef_list_item.stderr doc_nested_refdefs: do not falsely report checkboxes as refdefs 2025-06-26 09:19:59 -07:00
doc_overindented_list_items.fixed Merge commit '51d49c1ae2' into clippy-subtree-update 2025-01-28 19:33:54 +01:00
doc_overindented_list_items.rs Merge commit '51d49c1ae2' into clippy-subtree-update 2025-01-28 19:33:54 +01:00
doc_overindented_list_items.stderr Merge commit '51d49c1ae2' into clippy-subtree-update 2025-01-28 19:33:54 +01:00
doc_paragraphs_missing_punctuation.fixed doc_paragraphs_missing_punctuation: rename the lint 2025-10-19 17:02:31 +02:00
doc_paragraphs_missing_punctuation.rs doc_paragraphs_missing_punctuation: rename the lint 2025-10-19 17:02:31 +02:00
doc_paragraphs_missing_punctuation.stderr doc_paragraphs_missing_punctuation: update the lint suggestion help 2025-11-08 10:51:05 +01:00
doc_paragraphs_missing_punctuation_unfixable.rs doc_paragraphs_missing_punctuation: rename the lint 2025-10-19 17:02:31 +02:00
doc_paragraphs_missing_punctuation_unfixable.stderr doc_paragraphs_missing_punctuation: update the lint suggestion help 2025-11-08 10:51:05 +01:00
footnote_issue_13183.rs Update UI tests 2025-02-15 13:38:16 +01:00
issue_902.rs Update UI tests 2025-02-15 13:38:16 +01:00
issue_1832.rs Update UI tests 2025-02-15 13:38:16 +01:00
issue_9473.fixed Update UI tests 2025-02-15 13:38:16 +01:00
issue_9473.rs Update UI tests 2025-02-15 13:38:16 +01:00
issue_9473.stderr Show diff suggestion format on verbose replacement 2025-02-10 20:21:39 +00:00
issue_10262.fixed Merge commit '9d6f41691e' into clippy-subtree-update 2024-03-21 22:20:40 +01:00
issue_10262.rs Merge commit '9d6f41691e' into clippy-subtree-update 2024-03-21 22:20:40 +01:00
issue_10262.stderr Show diff suggestion format on verbose replacement 2025-02-10 20:21:39 +00:00
issue_12795.fixed Fix new tests updates 2025-02-15 13:38:42 +01:00
issue_12795.rs Fix new tests updates 2025-02-15 13:38:42 +01:00
issue_12795.stderr Show diff suggestion format on verbose replacement 2025-02-10 20:21:39 +00:00
link_adjacent.fixed doc_link_code: add check for text[adjacent] style links 2025-01-30 16:10:05 -07:00
link_adjacent.rs doc_link_code: add check for text[adjacent] style links 2025-01-30 16:10:05 -07:00
link_adjacent.stderr Merge remote-tracking branch 'upstream/master' into rustup 2025-02-20 15:26:07 +01:00
needless_doctest_main.rs Improve doc comment code language tag parsing, don't use a full parser 2025-10-27 22:01:06 +00:00
needless_doctest_main.stderr Improve doc comment code language tag parsing, don't use a full parser 2025-10-27 22:01:06 +00:00
unbalanced_ticks.rs Merge remote-tracking branch 'upstream/master' into rustup 2025-02-20 15:26:07 +01:00
unbalanced_ticks.stderr ui_test annotation cleanup 2025-02-16 16:51:35 +00:00