File tree 2 files changed +26
-1
lines changed
compiler/rustc_ast/src/util
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,10 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol {
52
52
// when we try to compute the "horizontal trim".
53
53
let lines = if kind == CommentKind :: Block {
54
54
// Whatever happens, we skip the first line.
55
- let mut i = if lines[ 0 ] . trim_start ( ) . starts_with ( '*' ) { 0 } else { 1 } ;
55
+ let mut i = lines
56
+ . get ( 0 )
57
+ . map ( |l| if l. trim_start ( ) . starts_with ( '*' ) { 0 } else { 1 } )
58
+ . unwrap_or ( 0 ) ;
56
59
let mut j = lines. len ( ) ;
57
60
58
61
while i < j && lines[ i] . trim ( ) . is_empty ( ) {
Original file line number Diff line number Diff line change
1
+ // Ensure that empty doc comments don't panic.
2
+
3
+ /*!
4
+ */
5
+
6
+ ///
7
+ ///
8
+ pub struct Foo ;
9
+
10
+ #[ doc = "
11
+ " ]
12
+ pub mod Mod {
13
+ //!
14
+ //!
15
+ }
16
+
17
+ /**
18
+ */
19
+ pub mod Another {
20
+ #![ doc = "
21
+ " ]
22
+ }
You can’t perform that action at this time.
0 commit comments