Rollup merge of #90657 - GuillaumeGomez:one-char-last-line-removed, r=jyn514

Fix bug with `#[doc]` string single-character last lines

Fixes #90618.

This is because `.iter().all(|c| c == '*')` returns `true` if there is no character checked. And in case the last line has only one character, it simply returns `true`, making the last line behind removed.
This commit is contained in:
Guillaume Gomez
2021-11-08 15:15:24 +01:00
committed by GitHub
3 changed files with 10 additions and 1 deletions

View File

@@ -38,7 +38,7 @@ pub fn beautify_doc_string(data: Symbol) -> Symbol {
i += 1; i += 1;
} }
// like the first, a last line of all stars should be omitted // like the first, a last line of all stars should be omitted
if j > i && lines[j - 1].chars().skip(1).all(|c| c == '*') { if j > i && !lines[j - 1].is_empty() && lines[j - 1].chars().all(|c| c == '*') {
j -= 1; j -= 1;
} }

View File

@@ -0,0 +1,7 @@
#![crate_name = "foo"]
#![no_std]
// @has 'foo/fn.foo.html'
// @has - '//*[@class="docblock"]' 'inc2 x'
#[doc = include_str!("short-line.md")]
pub fn foo() {}

View File

@@ -0,0 +1,2 @@
inc2
x