Skip to content

doc_link_with_quotes activates for JSON arrays #15878

@MultisampledNight

Description

@MultisampledNight

Summary

Some crates (e.g. clap) interpret doc comments literally and not as markdown, in which case JSON examples may be helpful for e.g. demonstration purposes.

Idea for a fix: Check if the intended-to-be doclink can even be one, as would not be the case with e.g. containing spaces.
(more hacky possibility would be to parse JSON and see if it's 1. an array 2. consisting of strings 3. with more than 1 item)

Came up in https://github.com/fioncat/otree/pull/93/files#diff-ce6e52385823f89d6bf1ea627c887cfd2a80b6fb8fc97932e5e3a9372d4ad7bbR20-R22.

Lint Name

doc_link_with_quotes

Reproducer

I tried this code:

#![deny(clippy::doc_link_with_quotes)]
//! ["a", "b"]

I saw this happen:

error: possible intra-doc link using quotes instead of backticks
 --> src/main.rs:2:6
  |
2 | //! ["a", "b"]
  |      ^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_link_with_quotes
note: the lint level is defined here
 --> src/main.rs:1:9
  |
1 | #![deny(clippy::doc_link_with_quotes)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I expected to see this happen:

(nothing, as ["a", "b"] is evidently not intended to be a doclink)

Version

rustc 1.92.0-nightly (2300c2aef 2025-10-12)
binary: rustc
commit-hash: 2300c2aef7dbc2a7bbbeaa9894d07d459abd9bc6
commit-date: 2025-10-12
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.2

Additional Labels

@rustbot label +L-pedantic +P-low

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveL-pedanticLint: Belongs in the pedantic lint groupP-lowPriority: Low

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions