From 5db71529626ca7c8316b93c4763cf3b2f1989a95 Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Thu, 11 Jun 2020 23:17:38 -0500 Subject: [PATCH] fix: backport fix for #4020 --- src/comment.rs | 10 ++++++---- tests/target/issue-4020.rs | 9 +++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 tests/target/issue-4020.rs diff --git a/src/comment.rs b/src/comment.rs index 518f2bcda0c38..7a0183f59af66 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -91,8 +91,9 @@ impl<'a> CommentStyle<'a> { | CommentStyle::TripleSlash | CommentStyle::Custom(..) | CommentStyle::Doc => "", - CommentStyle::DoubleBullet => " **/", - CommentStyle::SingleBullet | CommentStyle::Exclamation => " */", + CommentStyle::SingleBullet | CommentStyle::DoubleBullet | CommentStyle::Exclamation => { + " */" + } } } @@ -101,8 +102,9 @@ impl<'a> CommentStyle<'a> { CommentStyle::DoubleSlash => "// ", CommentStyle::TripleSlash => "/// ", CommentStyle::Doc => "//! ", - CommentStyle::SingleBullet | CommentStyle::Exclamation => " * ", - CommentStyle::DoubleBullet => " ** ", + CommentStyle::SingleBullet | CommentStyle::DoubleBullet | CommentStyle::Exclamation => { + " * " + } CommentStyle::Custom(opener) => opener, } } diff --git a/tests/target/issue-4020.rs b/tests/target/issue-4020.rs new file mode 100644 index 0000000000000..f29ecec028b77 --- /dev/null +++ b/tests/target/issue-4020.rs @@ -0,0 +1,9 @@ +// rustfmt-wrap_comments: true + +/** foobar */ +const foo1: u32 = 0; + +/** + * foobar + */ +const foo2: u32 = 0;