Skip to content

Commit 2d0cfb8

Browse files
authored
fix Issue 4020: problem reformatting block comments (#4071)
* add failing test * fix * remove source test file
1 parent 1e9af9f commit 2d0cfb8

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

rustfmt-core/rustfmt-lib/src/comment.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ impl<'a> CommentStyle<'a> {
9292
| CommentStyle::TripleSlash
9393
| CommentStyle::Custom(..)
9494
| CommentStyle::Doc => "",
95-
CommentStyle::DoubleBullet => " **/",
96-
CommentStyle::SingleBullet | CommentStyle::Exclamation => " */",
95+
CommentStyle::SingleBullet | CommentStyle::DoubleBullet | CommentStyle::Exclamation => {
96+
" */"
97+
}
9798
}
9899
}
99100

@@ -102,8 +103,9 @@ impl<'a> CommentStyle<'a> {
102103
CommentStyle::DoubleSlash => "// ",
103104
CommentStyle::TripleSlash => "/// ",
104105
CommentStyle::Doc => "//! ",
105-
CommentStyle::SingleBullet | CommentStyle::Exclamation => " * ",
106-
CommentStyle::DoubleBullet => " ** ",
106+
CommentStyle::SingleBullet | CommentStyle::DoubleBullet | CommentStyle::Exclamation => {
107+
" * "
108+
}
107109
CommentStyle::Custom(opener) => opener,
108110
}
109111
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// rustfmt-wrap_comments: true
2+
3+
/** foobar */
4+
const foo1: u32 = 0;
5+
6+
/**
7+
* foobar
8+
*/
9+
const foo2: u32 = 0;

0 commit comments

Comments
 (0)