Skip to content

rustdoc::unescaped_backticks only fires on the first item #141827

Open
@lolbinarycat

Description

@lolbinarycat

Code

#[warn(rustdoc::unescaped_backticks)]

pub fn foo() {}

#[doc = "`"]
pub fn bar() {}

Current output

[none]

Desired output

warning: unescaped backtick
 --> src/lib.rs:5:10
  |
5 | #[doc = "`"]
  |          ^
  |
  = help: the opening or closing backtick of an inline code may be missing
  = help: if you meant to use a literal backtick, escape it
           change: `
          to this: \`
note: the lint level is defined here
 --> src/lib.rs:1:8
  |
1 | #[warn(rustdoc::unescaped_backticks)]
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Rationale and extra context

No response

Other cases

Rust Version

rustc 1.89.0-nightly (70b3f4666 2025-05-30)
binary: rustc
commit-hash: 70b3f4666e24ce22fc32f5e357dbcf85d3254e63
commit-date: 2025-05-30
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5

Anything else?

removing fn foo causes the warning to be emitted properly.

also works with regular doc comments, and even if the first item is not public.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions