Skip to content

Commit 5dd1684

Browse files
authored
fix: index out of bound on empty comment
1 parent e2661ba commit 5dd1684

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

compiler/rustc_ast/src/util/comments.rs

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol {
4444
}
4545

4646
fn get_horizontal_trim<'a>(lines: &'a [&str], kind: CommentKind) -> Option<String> {
47+
if lines.is_empty() {
48+
return None;
49+
}
50+
4751
let mut i = usize::MAX;
4852
let mut first = true;
4953

0 commit comments

Comments
 (0)