Skip to content

doc_markdown lint's underlining shifted and recommendations made incorrect by escapes #10263

Closed
rust-lang/rust
#115689
@Enyium

Description

@Enyium

Summary

When using backslash escapes in a doc comment, following doc_markdown lint warnings in the same line are shifted to the left by the number of escapes (backslash characters) used before.

This could possibly also apply to other lints.

Reproducer

I tried this code:

/// Foo \[bar\] \[baz\] \[qux\]. I will now trigger an incorrect DocMarkdownLint. Twice: http://example.com/
/// This is correct: http://example.com/
type Test = String;

I expected to see this happen:

In the first doc comment line, DocMarkdownLint and http://example.com/ should be underlined.

Instead, this happened:

In the first doc comment line, rrect DocMarkdo and wice: http://examp are underlined.

Diagnostic message 1:

warning: item in documentation is missing backticks
   --> [...].rs:257:60
    |
257 | /// Foo \[bar\] \[baz\] \[qux\]. I will now trigger an incorrect DocMarkdownLint. Twice: http://example.com/
    |                                                            ^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
note: the lint level is defined here
   --> [...].rs:1:9
    |
1   | #![warn(clippy::pedantic)]
    |         ^^^^^^^^^^^^^^^^
    = note: `#[warn(clippy::doc_markdown)]` implied by `#[warn(clippy::pedantic)]`
help: try
    |
257 | /// Foo \[bar\] \[baz\] \[qux\]. I will now trigger an inco`rrect DocMarkdo`wnLint. Twice: http://example.com/
    |                                                            ~~~~~~~~~~~~~~~~~

Diagnostic message 2:

warning: you should put bare URLs between `<`/`>` or make a proper Markdown link
   --> [...].rs:257:84
    |
257 | /// Foo \[bar\] \[baz\] \[qux\]. I will now trigger an incorrect DocMarkdownLint. Twice: http://example.com/
    |                                                                                    ^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown

Version

rustc 1.67.0 (fc594f156 2023-01-24)
binary: rustc
commit-hash: fc594f15669680fa70d255faec3ca3fb507c3405
commit-date: 2023-01-24
host: x86_64-pc-windows-msvc
release: 1.67.0
LLVM version: 15.0.6

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions