Skip to content

too_long_first_doc_paragraph only considers markdown source not the rendered output #13315

Open
@Freax13

Description

@Freax13

Summary

too_long_first_doc_paragraph doesn't take into account that the length of the markdown source is not necessarily the length of the rendered output e.g. the raw markdown for the link [foo](barbaz) contains 13 bytes, but the rendered output is only 3 bytes. This leads to warnings about short paragraphs with long links.

Lint Name

too_long_first_doc_paragraph

Reproducer

I tried this code:

/// This doc comment contains two references: [this](https://fooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com)
/// and [this](https://fooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com)
pub fn foo() {}

I saw this happen:

warning: first doc comment paragraph is too long
 --> src/lib.rs:1:1
  |
1 | / /// This doc comment contains two references: [this](https://fooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com)
2 | | /// and [this](https://fooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com)
  | |_
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_long_first_doc_paragraph
  = note: `#[warn(clippy::too_long_first_doc_paragraph)]` on by default

I expected to see this happen: No warning

Version

rustc 1.82.0-nightly (1f12b9b0f 2024-08-27)
binary: rustc
commit-hash: 1f12b9b0fdbe735968ac002792a720f0ba4faca6
commit-date: 2024-08-27
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

Additional Labels

No response

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 have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions