diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 4e164d33a05..17d868f1ec8 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -549,7 +549,7 @@ fn check_doc<'a, Events: Iterator, Range { let (begin, span) = get_current_span(spans, range.start); paragraph_span = paragraph_span.with_hi(span.hi()); - ticks_unbalanced |= text.contains('`'); + ticks_unbalanced |= text.contains('`') && !in_code; if Some(&text) == in_link.as_ref() || ticks_unbalanced { // Probably a link of the form `` // Which are represented as a link to "http://example.com" with diff --git a/tests/ui/doc/unbalanced_ticks.rs b/tests/ui/doc/unbalanced_ticks.rs index 78e87bc6906..8e8324b30f0 100644 --- a/tests/ui/doc/unbalanced_ticks.rs +++ b/tests/ui/doc/unbalanced_ticks.rs @@ -34,3 +34,10 @@ fn in_code_block() {} /// - This `item has unbalanced tick marks /// - This item needs backticks_here fn other_markdown() {} + +#[rustfmt::skip] +/// - ```rust +/// /// `lol` +/// pub struct Struct; +/// ``` +fn iss_7421() {}