Merge pull request #3577 from topecongiro/issue-3575

Insert an empty line when normalizing `#[doc = ""]`
This commit is contained in:
Seiichi Uchida 2019-05-22 10:49:12 +09:00 committed by GitHub
commit 72ca0e5f2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View File

@ -12,6 +12,12 @@ impl Display for DocCommentFormatter<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
let opener = self.style.opener().trim_end();
let mut lines = self.literal.lines().peekable();
// Handle `#[doc = ""]`.
if lines.peek().is_none() {
return write!(formatter, "{}", opener);
}
while let Some(line) = lines.next() {
let is_last_line = lines.peek().is_none();
if is_last_line {

View File

@ -5,3 +5,8 @@
is split
on multiple lines"]
fn foo() {}
#[doc = " B1"]
#[doc = ""]
#[doc = " A1"]
fn bar() {}

View File

@ -5,3 +5,8 @@
///is split
///on multiple lines
fn foo() {}
/// B1
///
/// A1
fn bar() {}