Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue 4020: problem reformatting block comments #4071

Merged
merged 3 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions rustfmt-core/rustfmt-lib/src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
" */"
}
}
}

Expand All @@ -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,
}
}
Expand Down
9 changes: 9 additions & 0 deletions rustfmt-core/rustfmt-lib/tests/source/issue-4020.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// rustfmt-wrap_comments: true

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's mentioned in the Contributing docs, but for awareness, when the test is just ensuring rustfmt doesn't modify the formatting like this one you only need the test file under target and can skip the one under source

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that! Removed now.

/** foobar */
const foo1: u32 = 0;

/**
* foobar
*/
const foo2: u32 = 0;
9 changes: 9 additions & 0 deletions rustfmt-core/rustfmt-lib/tests/target/issue-4020.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// rustfmt-wrap_comments: true

/** foobar */
const foo1: u32 = 0;

/**
* foobar
*/
const foo2: u32 = 0;