File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -347,13 +347,19 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>(
347347 }
348348 } else {
349349 let mut br_with_padding = String :: with_capacity ( 6 * indent + 28 ) ;
350- br_with_padding. push_str ( " \n " ) ;
350+ br_with_padding. push ( '\n' ) ;
351351
352- let padding_amount =
353- if ending == Ending :: Newline { indent + 4 } else { indent + "fn where " . len ( ) } ;
352+ let where_indent = 3 ;
353+ let padding_amount = if ending == Ending :: Newline {
354+ indent + 4
355+ } else if indent == 0 {
356+ 4
357+ } else {
358+ indent + where_indent + "where " . len ( )
359+ } ;
354360
355361 for _ in 0 ..padding_amount {
356- br_with_padding. push_str ( " " ) ;
362+ br_with_padding. push ( ' ' ) ;
357363 }
358364 let where_preds = where_preds. to_string ( ) . replace ( '\n' , & br_with_padding) ;
359365
@@ -370,7 +376,8 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>(
370376 let where_preds = where_preds. replacen ( & br_with_padding, " " , 1 ) ;
371377
372378 let mut clause = br_with_padding;
373- clause. truncate ( clause. len ( ) - "where " . len ( ) ) ;
379+ // +1 is for `\n`.
380+ clause. truncate ( indent + 1 + where_indent) ;
374381
375382 write ! ( clause, "<span class=\" where\" >where{where_preds}</span>" ) ?;
376383 clause
Original file line number Diff line number Diff line change @@ -859,8 +859,8 @@ fn assoc_method(
859859 w. reserve ( header_len + "<a href=\" \" class=\" fn\" >{" . len ( ) + "</a>" . len ( ) ) ;
860860 write ! (
861861 w,
862- "{indent}{vis}{constness}{asyncness}{unsafety}{defaultness}{abi}fn <a{href} class= \" fn \" >{name}</a> \
863- {generics}{decl}{notable_traits}{where_clause}",
862+ "{indent}{vis}{constness}{asyncness}{unsafety}{defaultness}{abi}fn \
863+ <a{href} class= \" fn \" >{name}</a> {generics}{decl}{notable_traits}{where_clause}",
864864 indent = indent_str,
865865 vis = vis,
866866 constness = constness,
You can’t perform that action at this time.
0 commit comments