File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -138,15 +138,13 @@ pub fn docs_from_attrs(attrs: &hir::Attrs) -> Option<String> {
138138 for doc in docs {
139139 // str::lines doesn't yield anything for the empty string
140140 if !doc. is_empty ( ) {
141- buf. extend ( Itertools :: intersperse (
142- doc. lines ( ) . map ( |line| {
143- line. char_indices ( )
144- . nth ( indent)
145- . map_or ( line, |( offset, _) | & line[ offset..] )
146- . trim_end ( )
147- } ) ,
148- "\n " ,
149- ) ) ;
141+ // We don't trim trailing whitespace from doc comments as multiple trailing spaces
142+ // indicates a hard line break in Markdown.
143+ let lines = doc. lines ( ) . map ( |line| {
144+ line. char_indices ( ) . nth ( indent) . map_or ( line, |( offset, _) | & line[ offset..] )
145+ } ) ;
146+
147+ buf. extend ( Itertools :: intersperse ( lines, "\n " ) ) ;
150148 }
151149 buf. push ( '\n' ) ;
152150 }
You can’t perform that action at this time.
0 commit comments