Skip to content

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

@ojeda

Description

@ojeda

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, thus the equivalent lint for that may be a good idea as well. Either way, 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;
/// ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions