Skip to content

Commit 47bb327

Browse files
committed
Fix
1 parent fca3774 commit 47bb327

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

clippy_lints/src/doc.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,17 @@ fn lint_for_missing_headers(
456456
pub fn strip_doc_comment_decoration(doc: &str, comment_kind: CommentKind, span: Span) -> (String, Vec<(usize, Span)>) {
457457
fn get_line_indentation(line: &Vec<char>) -> u32 {
458458
let mut indent = 0;
459+
let mut smallest_indent = 0;
459460
for c in line {
460461
if *c == ' ' {
461462
indent += 1;
462-
} else if *c == '\n' {
463-
indent += 4;
464-
}; // Standard "Tab" space
463+
} else {
464+
if smallest_indent > indent {
465+
smallest_indent = indent;
466+
}
467+
indent = 0;
468+
continue;
469+
}
465470
}
466471
indent
467472
}
@@ -496,7 +501,8 @@ pub fn strip_doc_comment_decoration(doc: &str, comment_kind: CommentKind, span:
496501
let mut new_doc = Vec::new();
497502
for line in doc.lines() {
498503
if line.len() >= least_indented as usize {
499-
new_doc.push(&line[least_indented.saturating_sub(1) as usize..]); // Sometimes users start the comment the same line the doc comment is defined.
504+
505+
new_doc.push(&line[least_indented as usize..]); // Sometimes users start the comment the same line the doc comment is defined.
500506
// /** Example of this behaviour
501507
// (Some description)
502508
// */

tests/ui/doc_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![warn(clippy::missing_errors_doc)]
1+
#![warn(clippy::missing_errors_doc, clippy::doc_markdown)]
22
#![allow(clippy::result_unit_err)]
33
#![allow(clippy::unnecessary_wraps)]
44

0 commit comments

Comments
 (0)