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

Unneeded rust as language in rustdoc's documentation examples #13604

Open
ojeda opened this issue Oct 25, 2024 · 3 comments
Open

Unneeded rust as language in rustdoc's documentation examples #13604

ojeda opened this issue Oct 25, 2024 · 3 comments
Labels
A-lint Area: New lints

Comments

@ojeda
Copy link
Contributor

ojeda commented Oct 25, 2024

What it does

In a documentation example, when processed by rustdoc, it is strictly equivalent to write rust or not (https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html).

Thus it would be nice to have a lint that suggest the removal of the unneeded rust as language for the example.

Some projects may prefer the opposite, i.e. always writing rust, but consistency is typically an improvement.

Advantage

  • Less busy, and more consistent, source code.
  • When contributing to a project, there is no need to remember if it is supposed to be written or not.

Drawbacks

  • It may be slightly harder to copy the code into a non-rustdoc system.

Example

/// ```rust
/// let x = 5;
/// ```

Could be written as:

/// ```
/// let x = 5;
/// ```
@GnomedDev
Copy link
Contributor

Should this be a part of clippy? This seems like a better fit for a rustdoc warning, as it has all the markdown parsing code already.

@ojeda
Copy link
Contributor Author

ojeda commented Oct 26, 2024

Yeah, that may be right, I wasn't sure where to place it (there are other doc-related lints in Clippy already and perhaps rustdoc treats "stylistic diagnostics" like rustc, i.e. leaves those up to Clippy and other tools).

Cc @GuillaumeGomez

@GuillaumeGomez
Copy link
Member

I think it's actually a better idea to put it into clippy as a style lint because it's completely ok to add rust marker on a codeblock, even if useless in most cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

3 participants