From 1b9324063c88b7acad62798a2198d14fccde3a98 Mon Sep 17 00:00:00 2001 From: "Adam H. Leventhal" Date: Wed, 4 Mar 2020 17:44:53 -0800 Subject: [PATCH 1/3] add failing test --- rustfmt-core/rustfmt-lib/tests/source/issue-4020.rs | 9 +++++++++ rustfmt-core/rustfmt-lib/tests/target/issue-4020.rs | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 rustfmt-core/rustfmt-lib/tests/source/issue-4020.rs create mode 100644 rustfmt-core/rustfmt-lib/tests/target/issue-4020.rs diff --git a/rustfmt-core/rustfmt-lib/tests/source/issue-4020.rs b/rustfmt-core/rustfmt-lib/tests/source/issue-4020.rs new file mode 100644 index 00000000000..f29ecec028b --- /dev/null +++ b/rustfmt-core/rustfmt-lib/tests/source/issue-4020.rs @@ -0,0 +1,9 @@ +// rustfmt-wrap_comments: true + +/** foobar */ +const foo1: u32 = 0; + +/** + * foobar + */ +const foo2: u32 = 0; diff --git a/rustfmt-core/rustfmt-lib/tests/target/issue-4020.rs b/rustfmt-core/rustfmt-lib/tests/target/issue-4020.rs new file mode 100644 index 00000000000..f29ecec028b --- /dev/null +++ b/rustfmt-core/rustfmt-lib/tests/target/issue-4020.rs @@ -0,0 +1,9 @@ +// rustfmt-wrap_comments: true + +/** foobar */ +const foo1: u32 = 0; + +/** + * foobar + */ +const foo2: u32 = 0; From 61d6c08aa01ae1139083807874f8a1b3f3aac489 Mon Sep 17 00:00:00 2001 From: "Adam H. Leventhal" Date: Wed, 4 Mar 2020 22:34:03 -0800 Subject: [PATCH 2/3] fix --- rustfmt-core/rustfmt-lib/src/comment.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rustfmt-core/rustfmt-lib/src/comment.rs b/rustfmt-core/rustfmt-lib/src/comment.rs index 148bdf9670e..31faa9aa469 100644 --- a/rustfmt-core/rustfmt-lib/src/comment.rs +++ b/rustfmt-core/rustfmt-lib/src/comment.rs @@ -92,8 +92,9 @@ impl<'a> CommentStyle<'a> { | CommentStyle::TripleSlash | CommentStyle::Custom(..) | CommentStyle::Doc => "", - CommentStyle::DoubleBullet => " **/", - CommentStyle::SingleBullet | CommentStyle::Exclamation => " */", + CommentStyle::SingleBullet | CommentStyle::DoubleBullet | CommentStyle::Exclamation => { + " */" + } } } @@ -102,8 +103,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, } } From 347f8b5e7b3891bd985a14f3a9eb8e6eadfeea78 Mon Sep 17 00:00:00 2001 From: "Adam H. Leventhal" Date: Thu, 5 Mar 2020 22:16:36 -0800 Subject: [PATCH 3/3] remove source test file --- rustfmt-core/rustfmt-lib/tests/source/issue-4020.rs | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 rustfmt-core/rustfmt-lib/tests/source/issue-4020.rs diff --git a/rustfmt-core/rustfmt-lib/tests/source/issue-4020.rs b/rustfmt-core/rustfmt-lib/tests/source/issue-4020.rs deleted file mode 100644 index f29ecec028b..00000000000 --- a/rustfmt-core/rustfmt-lib/tests/source/issue-4020.rs +++ /dev/null @@ -1,9 +0,0 @@ -// rustfmt-wrap_comments: true - -/** foobar */ -const foo1: u32 = 0; - -/** - * foobar - */ -const foo2: u32 = 0;