-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove multiple trailing lines in comments
Previously, rustfmt would remove one blank, trailing line in a comment every time it ran, so formatting was not idempotent if a comment had multiple trailing lines. Comments are only reformatted in this way if `comment::rewrite_comment_inner` is called, which is enabled by any of the config options `normalize_comments`, `wrap_comments`, or `format_code_in_doc_comments` (for doc comments only). Absent those config options, no trailing line reformatting occurs at all. In this commit, when the existing condition that detects a blank, trailing line is true, any preceding blank lines are removed from the reformatted comment. A source/target "system test" was added to prevent regression. Signed-off-by: Ross Williams <[email protected]>
- Loading branch information
1 parent
d5f1200
commit fd95d0f
Showing
3 changed files
with
42 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// rustfmt-wrap_comments: true | ||
|
||
//! Module comment with multiple trailing lines | ||
//! | ||
//! | ||
|
||
/// Doc comment with multiple trailing lines | ||
/// | ||
/// | ||
pub mod foo {} | ||
|
||
/// Doc comment with one trailing line | ||
/// | ||
pub mod bar {} | ||
|
||
/* | ||
* Block comment with multiple trailing lines | ||
* | ||
* | ||
*/ | ||
pub mod block {} |
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,14 @@ | ||
// rustfmt-wrap_comments: true | ||
|
||
//! Module comment with multiple trailing lines | ||
|
||
/// Doc comment with multiple trailing lines | ||
pub mod foo {} | ||
|
||
/// Doc comment with one trailing line | ||
pub mod bar {} | ||
|
||
/* | ||
* Block comment with multiple trailing lines | ||
*/ | ||
pub mod block {} |