doc_lazy_continuation: Correctly count indent with backslashes (#13742)

changelog: [`doc_lazy_continuation`]: correctly count indent with
backslashes

Fixes #13705
This commit is contained in:
Jason Newcomb 2024-12-03 15:53:46 +00:00 committed by GitHub
commit 19426bfdfb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 1 deletions

View file

@ -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

View file

@ -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() {}

View file

@ -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() {}