File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
compiler/rustc_ast/src/util Expand file tree Collapse file tree 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 {
5252 // when we try to compute the "horizontal trim".
5353 let lines = if kind == CommentKind :: Block {
5454 // 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 ) ;
5659 let mut j = lines. len ( ) ;
5760
5861 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