diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-04-09 05:58:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-09 05:58:46 +0200 |
| commit | 8f4680e37caefc856fe3bb31d18c69f1e2b8cc16 (patch) | |
| tree | dc79220c1151a25b182b0ee5f9e402b632991a72 /compiler | |
| parent | 747bd16214444ca669934459aaee623ce24cc292 (diff) | |
| parent | 5e8bd9bbaaaa842e96a3ddef3a75208d0c96ffe7 (diff) | |
| download | rust-8f4680e37caefc856fe3bb31d18c69f1e2b8cc16.tar.gz rust-8f4680e37caefc856fe3bb31d18c69f1e2b8cc16.zip | |
Rollup merge of #95804 - GuillaumeGomez:empty-doc-comment-with-backline, r=notriddle
rustdoc: Fix empty doc comment with backline ICE Fixes #95800. r? ```@notriddle```
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_ast/src/util/comments.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_ast/src/util/comments.rs b/compiler/rustc_ast/src/util/comments.rs index f51b0086dc8..8730aeb0f3b 100644 --- a/compiler/rustc_ast/src/util/comments.rs +++ b/compiler/rustc_ast/src/util/comments.rs @@ -52,7 +52,10 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol { // when we try to compute the "horizontal trim". let lines = if kind == CommentKind::Block { // 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(); while i < j && lines[i].trim().is_empty() { |
