File tree 2 files changed +14
-7
lines changed
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>(
347
347
}
348
348
} else {
349
349
let mut br_with_padding = String :: with_capacity ( 6 * indent + 28 ) ;
350
- br_with_padding. push_str ( " \n " ) ;
350
+ br_with_padding. push ( '\n' ) ;
351
351
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
+ } ;
354
360
355
361
for _ in 0 ..padding_amount {
356
- br_with_padding. push_str ( " " ) ;
362
+ br_with_padding. push ( ' ' ) ;
357
363
}
358
364
let where_preds = where_preds. to_string ( ) . replace ( '\n' , & br_with_padding) ;
359
365
@@ -370,7 +376,8 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>(
370
376
let where_preds = where_preds. replacen ( & br_with_padding, " " , 1 ) ;
371
377
372
378
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) ;
374
381
375
382
write ! ( clause, "<span class=\" where\" >where{where_preds}</span>" ) ?;
376
383
clause
Original file line number Diff line number Diff line change @@ -859,8 +859,8 @@ fn assoc_method(
859
859
w. reserve ( header_len + "<a href=\" \" class=\" fn\" >{" . len ( ) + "</a>" . len ( ) ) ;
860
860
write ! (
861
861
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}",
864
864
indent = indent_str,
865
865
vis = vis,
866
866
constness = constness,
You can’t perform that action at this time.
0 commit comments