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

too_long_first_doc_paragraph incorrect suggestion for module-level doc #13309

Closed
AsakuraMizu opened this issue Aug 26, 2024 · 1 comment · Fixed by #13377
Closed

too_long_first_doc_paragraph incorrect suggestion for module-level doc #13309

AsakuraMizu opened this issue Aug 26, 2024 · 1 comment · Fixed by #13377
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@AsakuraMizu
Copy link

AsakuraMizu commented Aug 26, 2024

Summary

Related PR: #12993

For too_long_first_doc_paragraph in module-level doc, it should suggest to add an empty line with //! under certain conditions. However, the current implementation will suggest to add /// only.

The module-level doc is specified because I found this rule not checking crate-level doc, which may be another issue.

Reproducer

I tried this code:

// in lib.rs
pub mod foo;

// in foo.rs
//! A very short summary.
//! A much longer explanation that goes into a lot more detail about
//! how the thing works, possibly with doclinks and so one,
//! and probably spanning a many rows. Blablabla, it needs to be over
//! 200 characters so I needed to write something longeeeeeeer.

I expected to see this happen:

warning: first doc comment paragraph is too long
 --> src/foo.rs:1:1
  |
1 | / //! A very short summary.
2 | | //! A much longer explanation that goes into a lot more detail about
3 | | //! how the thing works, possibly with doclinks and so one,
4 | | //! and probably spanning a many rows. Blablabla, it needs to be over
5 | | //! 200 characters so I needed to write something longeeeeeeer.
  | |_
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_long_first_doc_paragraph
  = note: `#[warn(clippy::too_long_first_doc_paragraph)]` on by default
help: add an empty line
  |
1 ~ //! A very short summary.
2 + //!
  |

Instead, this happened:

warning: first doc comment paragraph is too long
 --> src/foo.rs:1:1
  |
1 | / //! A very short summary.
2 | | //! A much longer explanation that goes into a lot more detail about
3 | | //! how the thing works, possibly with doclinks and so one,
4 | | //! and probably spanning a many rows. Blablabla, it needs to be over
5 | | //! 200 characters so I needed to write something longeeeeeeer.
  | |_
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_long_first_doc_paragraph
  = note: `#[warn(clippy::too_long_first_doc_paragraph)]` on by default
help: add an empty line
  |
1 ~ //! A very short summary.
2 + ///
  |

Version

rustc 1.82.0-nightly (c6db1ca3c 2024-08-25)
binary: rustc
commit-hash: c6db1ca3c93ad69692a4c4b5542f26fda4bf3aec
commit-date: 2024-08-25
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

Additional Labels

No response

@AsakuraMizu AsakuraMizu added the C-bug Category: Clippy is not doing the correct thing label Aug 26, 2024
@Alexendoo Alexendoo added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label Aug 26, 2024
@vHugoObject
Copy link
Contributor

@rustbot claim

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-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
4 participants
@Alexendoo @vHugoObject @AsakuraMizu and others