@@ -289,7 +289,7 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>(
289
289
if f. alternate ( ) {
290
290
f. write_str ( " " ) ?;
291
291
} else {
292
- f. write_str ( "<br> " ) ?;
292
+ f. write_str ( "\n " ) ?;
293
293
}
294
294
295
295
match pred {
@@ -352,24 +352,24 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>(
352
352
}
353
353
} else {
354
354
let mut br_with_padding = String :: with_capacity ( 6 * indent + 28 ) ;
355
- br_with_padding. push_str ( "<br> " ) ;
355
+ br_with_padding. push_str ( "\n " ) ;
356
356
357
357
let padding_amout =
358
358
if ending == Ending :: Newline { indent + 4 } else { indent + "fn where " . len ( ) } ;
359
359
360
360
for _ in 0 ..padding_amout {
361
361
br_with_padding. push_str ( " " ) ;
362
362
}
363
- let where_preds = where_preds. to_string ( ) . replace ( "<br> " , & br_with_padding) ;
363
+ let where_preds = where_preds. to_string ( ) . replace ( "\n " , & br_with_padding) ;
364
364
365
365
if ending == Ending :: Newline {
366
366
let mut clause = " " . repeat ( indent. saturating_sub ( 1 ) ) ;
367
367
write ! ( clause, "<span class=\" where fmt-newline\" >where{where_preds},</span>" ) ?;
368
368
clause
369
369
} else {
370
- // insert a <br> tag after a single space but before multiple spaces at the start
370
+ // insert a newline after a single space but before multiple spaces at the start
371
371
if indent == 0 {
372
- format ! ( "<br> <span class=\" where\" >where{where_preds}</span>" )
372
+ format ! ( "\n <span class=\" where\" >where{where_preds}</span>" )
373
373
} else {
374
374
// put the first one on the same line as the 'where' keyword
375
375
let where_preds = where_preds. replacen ( & br_with_padding, " " , 1 ) ;
@@ -1315,7 +1315,8 @@ impl clean::FnDecl {
1315
1315
1316
1316
/// * `header_len`: The length of the function header and name. In other words, the number of
1317
1317
/// characters in the function declaration up to but not including the parentheses.
1318
- /// <br>Used to determine line-wrapping.
1318
+ /// This is expected to go into a `<pre>`/`code-header` block, so indentation and newlines
1319
+ /// are preserved.
1319
1320
/// * `indent`: The number of spaces to indent each successive line with, if line-wrapping is
1320
1321
/// necessary.
1321
1322
pub ( crate ) fn full_print < ' a , ' tcx : ' a > (
@@ -1363,7 +1364,7 @@ impl clean::FnDecl {
1363
1364
}
1364
1365
} else {
1365
1366
if i > 0 {
1366
- args. push_str ( "<br> " ) ;
1367
+ args. push_str ( "\n " ) ;
1367
1368
}
1368
1369
if input. is_const {
1369
1370
args. push_str ( "const " ) ;
@@ -1389,7 +1390,7 @@ impl clean::FnDecl {
1389
1390
let mut args = args. into_inner ( ) ;
1390
1391
1391
1392
if self . c_variadic {
1392
- args. push_str ( ",<br> ..." ) ;
1393
+ args. push_str ( ",\n ..." ) ;
1393
1394
args_plain. push_str ( ", ..." ) ;
1394
1395
}
1395
1396
@@ -1399,24 +1400,20 @@ impl clean::FnDecl {
1399
1400
1400
1401
let declaration_len = header_len + args_plain. len ( ) + arrow_plain. len ( ) ;
1401
1402
let output = if declaration_len > 80 {
1402
- let full_pad = format ! ( "<br> {}" , " " . repeat( indent + 4 ) ) ;
1403
- let close_pad = format ! ( "<br> {}" , " " . repeat( indent) ) ;
1403
+ let full_pad = format ! ( "\n {}" , " " . repeat( indent + 4 ) ) ;
1404
+ let close_pad = format ! ( "\n {}" , " " . repeat( indent) ) ;
1404
1405
format ! (
1405
1406
"({pad}{args}{close}){arrow}" ,
1406
1407
pad = if self . inputs. values. is_empty( ) { "" } else { & full_pad } ,
1407
- args = args. replace( "<br> " , & full_pad) ,
1408
+ args = args. replace( "\n " , & full_pad) ,
1408
1409
close = close_pad,
1409
1410
arrow = arrow
1410
1411
)
1411
1412
} else {
1412
- format ! ( "({args}){arrow}" , args = args. replace( "<br> " , " " ) , arrow = arrow)
1413
+ format ! ( "({args}){arrow}" , args = args. replace( "\n " , " " ) , arrow = arrow)
1413
1414
} ;
1414
1415
1415
- if f. alternate ( ) {
1416
- write ! ( f, "{}" , output. replace( "<br>" , "\n " ) )
1417
- } else {
1418
- write ! ( f, "{}" , output)
1419
- }
1416
+ write ! ( f, "{}" , output)
1420
1417
}
1421
1418
}
1422
1419
0 commit comments