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

List item in doc comment starting with escaped [ makes clippy calculate indent wrong #13705

Open
maia-s opened this issue Nov 19, 2024 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@maia-s
Copy link

maia-s commented Nov 19, 2024

Summary

If a list item in a doc comment starts with \[ (to stop rustdoc from making a link), clippy calculates the expected indent for the rest of the lines of the list item incorrecly, suggesting to add additional indentation. A \] triggers this bug also, but e.g. \x doesn't.

This is both a false positive and a false negative bc clippy expects the wrong indentation

Playground

Reproducer

I tried this code:

/// - \[text in square brackets\] with a long following description
///   that goes over multiple lines
pub fn item() {}

I expected to see this happen:
No warning

Instead, this happened:
Clippy warns:

warning: doc list item without indentation
 --> src/lib.rs:2:5
  |
2 | ///   that goes over multiple lines
  |     ^^
  |
  = help: if this is supposed to be its own paragraph, add a blank line
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation
  = note: `#[warn(clippy::doc_lazy_continuation)]` on by default
help: indent this line
  |
2 | ///    that goes over multiple lines
  |       +

warning: `playground` (lib) generated 1 warning

Version

rustc 1.84.0-nightly (798fb83f7 2024-10-16)
binary: rustc
commit-hash: 798fb83f7d24e31b16acca113496f39ff168c143
commit-date: 2024-10-16
host: aarch64-apple-darwin
release: 1.84.0-nightly
LLVM version: 19.1.1

Additional Labels

@rustbot label +I-false-positive +I-false-negative

@maia-s maia-s added the C-bug Category: Clippy is not doing the correct thing label Nov 19, 2024
@rustbot rustbot added I-false-negative Issue: The lint should have been triggered on code, but wasn't I-false-positive Issue: The lint was triggered on code it shouldn't have labels Nov 19, 2024
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 I-false-negative Issue: The lint should have been triggered on code, but wasn't I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

2 participants