Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Enyium opened this issue Jan 30, 2023 · 0 comments · Fixed by rust-lang/rust#115689
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@Enyium
Copy link

Enyium commented Jan 30, 2023

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

@Enyium Enyium added the C-bug Category: Clippy is not doing the correct thing label Jan 30, 2023
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Sep 12, 2023
…nishearth,flip1995

Reuse rustdoc's doc comment handling in Clippy

Moves `source_span_for_markdown_range` and `span_of_attrs` (renamed to `span_of_fragments`) to `rustc_resolve::rustdoc` so it can be used in Clippy

Fixes rust-lang/rust-clippy#10277
Fixes rust-lang/rust-clippy#5593
Fixes rust-lang/rust-clippy#10263
Fixes rust-lang/rust-clippy#2581
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Sep 25, 2023
…nishearth,flip1995

Reuse rustdoc's doc comment handling in Clippy

Moves `source_span_for_markdown_range` and `span_of_attrs` (renamed to `span_of_fragments`) to `rustc_resolve::rustdoc` so it can be used in Clippy

Fixes rust-lang#10277
Fixes rust-lang#5593
Fixes rust-lang#10263
Fixes rust-lang#2581
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant