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:
commit
d9fc7d1041
@ -38,7 +38,7 @@ pub fn beautify_doc_string(data: Symbol) -> Symbol {
|
||||
i += 1;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
7
src/test/rustdoc/include_str_cut.rs
Normal file
7
src/test/rustdoc/include_str_cut.rs
Normal 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() {}
|
2
src/test/rustdoc/short-line.md
Normal file
2
src/test/rustdoc/short-line.md
Normal file
@ -0,0 +1,2 @@
|
||||
inc2
|
||||
x
|
Loading…
x
Reference in New Issue
Block a user