mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Rollup merge of #95804 - GuillaumeGomez:empty-doc-comment-with-backline, r=notriddle
rustdoc: Fix empty doc comment with backline ICE Fixes #95800. r? ```@notriddle```
This commit is contained in:
commit
8f4680e37c
@ -52,7 +52,10 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol {
|
|||||||
// when we try to compute the "horizontal trim".
|
// when we try to compute the "horizontal trim".
|
||||||
let lines = if kind == CommentKind::Block {
|
let lines = if kind == CommentKind::Block {
|
||||||
// Whatever happens, we skip the first line.
|
// Whatever happens, we skip the first line.
|
||||||
let mut i = if lines[0].trim_start().starts_with('*') { 0 } else { 1 };
|
let mut i = lines
|
||||||
|
.get(0)
|
||||||
|
.map(|l| if l.trim_start().starts_with('*') { 0 } else { 1 })
|
||||||
|
.unwrap_or(0);
|
||||||
let mut j = lines.len();
|
let mut j = lines.len();
|
||||||
|
|
||||||
while i < j && lines[i].trim().is_empty() {
|
while i < j && lines[i].trim().is_empty() {
|
||||||
|
22
src/test/rustdoc/empty-doc-comment.rs
Normal file
22
src/test/rustdoc/empty-doc-comment.rs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Ensure that empty doc comments don't panic.
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*/
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
pub struct Foo;
|
||||||
|
|
||||||
|
#[doc = "
|
||||||
|
"]
|
||||||
|
pub mod Mod {
|
||||||
|
//!
|
||||||
|
//!
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
pub mod Another {
|
||||||
|
#![doc = "
|
||||||
|
"]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user