From d3a7fb140c539be677db2ef0f7f93f6b5d0a19f1 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 27 Nov 2024 17:34:47 -0700 Subject: [PATCH] doc_lazy_continuation: Correctly count indent with backslashes changelog: [`doc_lazy_continuation`]: correctly count indent with backslashes --- clippy_lints/src/doc/mod.rs | 7 ++++++- tests/ui/doc/doc_lazy_list.fixed | 6 ++++++ tests/ui/doc/doc_lazy_list.rs | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index 2439ee237588..46571246052e 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -948,7 +948,12 @@ fn check_doc<'a, Events: Iterator, Range 0 && doc.as_bytes().get(start - 1) == Some(&b'\\') { + // backslashes aren't in the event stream... + start -= 1; + } + start - range.start } } else { 0 diff --git a/tests/ui/doc/doc_lazy_list.fixed b/tests/ui/doc/doc_lazy_list.fixed index da537518a2b5..0822cc7c6350 100644 --- a/tests/ui/doc/doc_lazy_list.fixed +++ b/tests/ui/doc/doc_lazy_list.fixed @@ -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() {} diff --git a/tests/ui/doc/doc_lazy_list.rs b/tests/ui/doc/doc_lazy_list.rs index 3cc18e35780a..068de140e00a 100644 --- a/tests/ui/doc/doc_lazy_list.rs +++ b/tests/ui/doc/doc_lazy_list.rs @@ -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() {}