Skip to content

Commit 19426bf

Browse files
authored
doc_lazy_continuation: Correctly count indent with backslashes (#13742)
changelog: [`doc_lazy_continuation`]: correctly count indent with backslashes Fixes #13705
2 parents 646d72a + d3a7fb1 commit 19426bf

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

clippy_lints/src/doc/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,12 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
948948
);
949949
refdefrange.start - range.start
950950
} else {
951-
next_range.start - range.start
951+
let mut start = next_range.start;
952+
if start > 0 && doc.as_bytes().get(start - 1) == Some(&b'\\') {
953+
// backslashes aren't in the event stream...
954+
start -= 1;
955+
}
956+
start - range.start
952957
}
953958
} else {
954959
0

tests/ui/doc/doc_lazy_list.fixed

+6
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,9 @@ fn seven() {}
7575
/// ]
7676
//~^ ERROR: doc list item without indentation
7777
fn eight() {}
78+
79+
#[rustfmt::skip]
80+
// https://github.com/rust-lang/rust-clippy/issues/13705
81+
/// - \[text in square brackets\] with a long following description
82+
/// that goes over multiple lines
83+
pub fn backslash_escaped_square_braces() {}

tests/ui/doc/doc_lazy_list.rs

+6
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,9 @@ fn seven() {}
7575
/// ]
7676
//~^ ERROR: doc list item without indentation
7777
fn eight() {}
78+
79+
#[rustfmt::skip]
80+
// https://github.com/rust-lang/rust-clippy/issues/13705
81+
/// - \[text in square brackets\] with a long following description
82+
/// that goes over multiple lines
83+
pub fn backslash_escaped_square_braces() {}

0 commit comments

Comments
 (0)