forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#13002 - notriddle:notriddle/blank-line, r=Man…
…ishearth doc_lazy_continuation: blank comment line for gap This change addresses cases where doc comments are separated by blank lines, comments, or non-doc-comment attributes, like this: ```rust /// - first line // not part of doc comment /// second line ``` Before this commit, Clippy gave a pedantically-correct warning about how you needed to indent the second line. This is unlikely to be what the user intends, and has been described as a "false positive." Since Clippy is warning you about a highly unintuitive behavior [that Rustdoc actually has](https://notriddle.com/rustdoc-html-demo-11/lazy-continuation-bad/test_dingus_2024/constant.D.html), we definitely want it to output *something*, but the suggestion to indent was poor. Fixes rust-lang#12917 ``` changelog: [`doc_lazy_continuation`]: suggest blank line for likely-unintended lazy continuations ```
- Loading branch information
Showing
11 changed files
with
246 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// https://github.com/rust-lang/rust-clippy/issues/12917 | ||
#![warn(clippy::doc_lazy_continuation)] | ||
|
||
/// This is a constant. | ||
/// | ||
/// The meaning of which should not be explained. | ||
pub const A: i32 = 42; | ||
|
||
/// This is another constant, no longer used. | ||
/// | ||
/// This block of documentation has a long | ||
/// explanation and derivation to explain | ||
/// why it is what it is, and how it's used. | ||
/// | ||
/// It is left here for historical reasons, and | ||
/// for reference. | ||
/// | ||
/// Reasons it's great: | ||
/// - First reason | ||
/// - Second reason | ||
/// | ||
//pub const B: i32 = 1337; | ||
|
||
/// This is yet another constant. | ||
/// | ||
/// This has a similar fate as `B`. | ||
/// | ||
/// Reasons it's useful: | ||
/// 1. First reason | ||
/// 2. Second reason | ||
/// | ||
//pub const C: i32 = 8008; | ||
|
||
/// This is still in use. | ||
pub const D: i32 = 20; | ||
|
||
/// > blockquote code path | ||
/// | ||
|
||
/// bottom text | ||
pub const E: i32 = 20; | ||
|
||
/// > blockquote code path | ||
/// | ||
#[repr(C)] | ||
/// bottom text | ||
pub struct Foo(i32); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// https://github.com/rust-lang/rust-clippy/issues/12917 | ||
#![warn(clippy::doc_lazy_continuation)] | ||
|
||
/// This is a constant. | ||
/// | ||
/// The meaning of which should not be explained. | ||
pub const A: i32 = 42; | ||
|
||
/// This is another constant, no longer used. | ||
/// | ||
/// This block of documentation has a long | ||
/// explanation and derivation to explain | ||
/// why it is what it is, and how it's used. | ||
/// | ||
/// It is left here for historical reasons, and | ||
/// for reference. | ||
/// | ||
/// Reasons it's great: | ||
/// - First reason | ||
/// - Second reason | ||
//pub const B: i32 = 1337; | ||
|
||
/// This is yet another constant. | ||
/// | ||
/// This has a similar fate as `B`. | ||
/// | ||
/// Reasons it's useful: | ||
/// 1. First reason | ||
/// 2. Second reason | ||
//pub const C: i32 = 8008; | ||
|
||
/// This is still in use. | ||
pub const D: i32 = 20; | ||
|
||
/// > blockquote code path | ||
|
||
/// bottom text | ||
pub const E: i32 = 20; | ||
|
||
/// > blockquote code path | ||
#[repr(C)] | ||
/// bottom text | ||
pub struct Foo(i32); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
error: doc list item without indentation | ||
--> tests/ui/doc/doc_lazy_blank_line.rs:23:5 | ||
| | ||
LL | /// This is yet another constant. | ||
| ^ | ||
| | ||
= help: if this is intended to be part of the list, indent 3 spaces | ||
= note: `-D clippy::doc-lazy-continuation` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::doc_lazy_continuation)]` | ||
help: if this should be its own paragraph, add a blank doc comment line | ||
| | ||
LL ~ /// - Second reason | ||
LL + /// | ||
| | ||
|
||
error: doc list item without indentation | ||
--> tests/ui/doc/doc_lazy_blank_line.rs:32:5 | ||
| | ||
LL | /// This is still in use. | ||
| ^ | ||
| | ||
= help: if this is intended to be part of the list, indent 4 spaces | ||
help: if this should be its own paragraph, add a blank doc comment line | ||
| | ||
LL ~ /// 2. Second reason | ||
LL + /// | ||
| | ||
|
||
error: doc quote line without `>` marker | ||
--> tests/ui/doc/doc_lazy_blank_line.rs:37:5 | ||
| | ||
LL | /// bottom text | ||
| ^ | ||
| | ||
= help: if this not intended to be a quote at all, escape it with `\>` | ||
help: if this should be its own paragraph, add a blank doc comment line | ||
| | ||
LL ~ /// > blockquote code path | ||
LL + /// | ||
| | ||
|
||
error: doc quote line without `>` marker | ||
--> tests/ui/doc/doc_lazy_blank_line.rs:42:5 | ||
| | ||
LL | /// bottom text | ||
| ^ | ||
| | ||
= help: if this not intended to be a quote at all, escape it with `\>` | ||
help: if this should be its own paragraph, add a blank doc comment line | ||
| | ||
LL ~ /// > blockquote code path | ||
LL + /// | ||
| | ||
|
||
error: aborting due to 4 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.