Skip to content

Commit ec5aa66

Browse files
doc_comments_missing_terminal_punctuation: handle code spans properly
1 parent 6d083ea commit ec5aa66

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

clippy_lints/src/doc/doc_comments_missing_terminal_punctuation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn is_missing_punctuation(doc_string: &str) -> Option<usize> {
6060
Event::InlineHtml(_) | Event::Start(Tag::Image { .. }) | Event::End(TagEnd::Image) => {
6161
text_offset = None;
6262
},
63-
Event::Text(..) | Event::Start(Tag::Link { .. }) | Event::End(TagEnd::Link)
63+
Event::Code(..) | Event::Text(..) | Event::Start(Tag::Link { .. }) | Event::End(TagEnd::Link)
6464
if no_report_depth == 0 && !offset.is_empty() =>
6565
{
6666
text_offset = Some(offset);

tests/ui/doc/doc_comments_missing_terminal_punctuation.fixed

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ struct OnlyLastSentence;
141141
/// ```
142142
struct IncompleteBlockCode;
143143

144+
/// This ends with a code `span`.
145+
//~^ doc_comments_missing_terminal_punctuation
146+
struct CodeSpan;
147+
144148
#[expect(clippy::empty_docs)]
145149
///
146150
struct EmptyDocComment;

tests/ui/doc/doc_comments_missing_terminal_punctuation.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ struct OnlyLastSentence;
141141
/// ```
142142
struct IncompleteBlockCode;
143143

144+
/// This ends with a code `span`
145+
//~^ doc_comments_missing_terminal_punctuation
146+
struct CodeSpan;
147+
144148
#[expect(clippy::empty_docs)]
145149
///
146150
struct EmptyDocComment;

tests/ui/doc/doc_comments_missing_terminal_punctuation.stderr

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,16 @@ LL | /// Only the last sentence is
8686
| ^ help: end the doc comment with some punctuation: `.`
8787

8888
error: doc comments should end with a terminal punctuation mark
89-
--> tests/ui/doc/doc_comments_missing_terminal_punctuation.rs:149:27
89+
--> tests/ui/doc/doc_comments_missing_terminal_punctuation.rs:144:33
90+
|
91+
LL | /// This ends with a code `span`
92+
| ^ help: end the doc comment with some punctuation: `.`
93+
94+
error: doc comments should end with a terminal punctuation mark
95+
--> tests/ui/doc/doc_comments_missing_terminal_punctuation.rs:153:27
9096
|
9197
LL | * Block doc comments work
9298
| ^ help: end the doc comment with some punctuation: `.`
9399

94-
error: aborting due to 15 previous errors
100+
error: aborting due to 16 previous errors
95101

0 commit comments

Comments
 (0)