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

(false positive) doc_markdown should disregard escaped underscores #2581

Closed
lorepozo opened this issue Mar 27, 2018 · 3 comments · Fixed by rust-lang/rust#115689
Closed

(false positive) doc_markdown should disregard escaped underscores #2581

lorepozo opened this issue Mar 27, 2018 · 3 comments · Fixed by rust-lang/rust#115689
Labels
C-bug Category: Clippy is not doing the correct thing S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work

Comments

@lorepozo
Copy link

If a docstring has an escaped underscore (\_), then clippy should treat that escaped underscore as any other (insignificant) character.

// lib.rs
//! Suppose a web LaTeX viewer is loaded.
//! (Note that backslashes are escaped for LaTeX.)
//!
//! \\[
//!     \\prod\_{x\\in X} p\_x
//! \\]

results in

warning: you should put `prod_{x\in` between ticks in the documentation
 --> src/lib.rs:5:10
  |
5 | //!     \\prod\_{x\\in X} p\_x
  |          ^^^^^^^^^^
  |
  = note: #[warn(doc_markdown)] on by default
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.190/index.html#doc_markdown

warning: you should put `p_x` between ticks in the documentation
 --> src/lib.rs:5:24
  |
5 | //!     \\prod\_{x\\in X} p\_x
  |                        ^^^
  |
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.190/index.html#doc_markdown
@lorepozo
Copy link
Author

This was on clippy-0.0.190.

@phansch phansch added the C-bug Category: Clippy is not doing the correct thing label Mar 30, 2018
@phansch
Copy link
Member

phansch commented Dec 7, 2018

It looks like this is caused by us using pulldown_cmark which is turning

\\prod\_{x\\in X} p\_x

into

\prod_{x\in X} p_x

The lint then splits this up into the words \prod_{x\in X} and p_x which are both causing the lint to trigger.
Due to the backslashes being trimmed by pulldown_cmark, there's nothing we can do about that right now, unfortunately.

@phansch phansch added E-hard Call for participation: This a hard problem and requires more experience or effort to work on S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work and removed E-hard Call for participation: This a hard problem and requires more experience or effort to work on labels Dec 18, 2020
@hellow554
Copy link
Contributor

This is still an issue today. Any updates on this (after 3 years? :) )

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 S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants