Skip to content

Commit

Permalink
doc_lazy_continuation: Correctly count indent with backslashes (#13742)
Browse files Browse the repository at this point in the history
changelog: [`doc_lazy_continuation`]: correctly count indent with
backslashes

Fixes #13705
  • Loading branch information
Jarcho authored Dec 3, 2024
2 parents 646d72a + d3a7fb1 commit 19426bf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion clippy_lints/src/doc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,12 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
);
refdefrange.start - range.start
} else {
next_range.start - range.start
let mut start = next_range.start;
if start > 0 && doc.as_bytes().get(start - 1) == Some(&b'\\') {
// backslashes aren't in the event stream...
start -= 1;
}
start - range.start
}
} else {
0
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/doc/doc_lazy_list.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ fn seven() {}
/// ]
//~^ ERROR: doc list item without indentation
fn eight() {}

#[rustfmt::skip]
// https://github.com/rust-lang/rust-clippy/issues/13705
/// - \[text in square brackets\] with a long following description
/// that goes over multiple lines
pub fn backslash_escaped_square_braces() {}
6 changes: 6 additions & 0 deletions tests/ui/doc/doc_lazy_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ fn seven() {}
/// ]
//~^ ERROR: doc list item without indentation
fn eight() {}

#[rustfmt::skip]
// https://github.com/rust-lang/rust-clippy/issues/13705
/// - \[text in square brackets\] with a long following description
/// that goes over multiple lines
pub fn backslash_escaped_square_braces() {}

0 comments on commit 19426bf

Please sign in to comment.