rust-lang / rust-lang/rust-clippy

Detect extra "base indentation" in Rust code blocks in docs

Open
#15,025 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint G-Rust-for-Linux
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

What it does

For Rust code blocks, and for code blocks in many other languages, it is very likely that extra indentation is not indented if it is applied across the entire contents of the code block, e.g. an extra space on all lines (or even just all non-empty lines).

Having said that, when/if rustfmt stabilizes formatting code blocks in documentation, this lint may not be needed anymore.

Possibly related, at least implementation-wise: https://github.com/rust-lang/rust-clippy/issues/15023 and https://github.com/rust-lang/rust-clippy/issues/15024.

Advantage
  • More consistency in docs.
  • Less time spent by reviewers.
Drawbacks

No response

Example
/// ```
///  fn f() {}
/// ```

Should be written as:

/// ```
/// fn f() {}
/// ```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Rust documentation code-block example in this issue and review the related Clippy issues 15023 and 15024 for implementation context. Done means a lint detects uniform extra indentation in Rust documentation code blocks and reports the example shown, while accounting for the stated possibility that rustfmt may make it unnecessary.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.