@@ -289,7 +289,7 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>(
289289 if f. alternate ( ) {
290290 f. write_str ( " " ) ?;
291291 } else {
292- f. write_str ( "<br> " ) ?;
292+ f. write_str ( "\n " ) ?;
293293 }
294294
295295 match pred {
@@ -352,24 +352,24 @@ pub(crate) fn print_where_clause<'a, 'tcx: 'a>(
352352 }
353353 } else {
354354 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 " ) ;
356356
357357 let padding_amout =
358358 if ending == Ending :: Newline { indent + 4 } else { indent + "fn where " . len ( ) } ;
359359
360360 for _ in 0 ..padding_amout {
361361 br_with_padding. push_str ( " " ) ;
362362 }
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) ;
364364
365365 if ending == Ending :: Newline {
366366 let mut clause = " " . repeat ( indent. saturating_sub ( 1 ) ) ;
367367 write ! ( clause, "<span class=\" where fmt-newline\" >where{where_preds},</span>" ) ?;
368368 clause
369369 } 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
371371 if indent == 0 {
372- format ! ( "<br> <span class=\" where\" >where{where_preds}</span>" )
372+ format ! ( "\n <span class=\" where\" >where{where_preds}</span>" )
373373 } else {
374374 // put the first one on the same line as the 'where' keyword
375375 let where_preds = where_preds. replacen ( & br_with_padding, " " , 1 ) ;
@@ -1315,7 +1315,8 @@ impl clean::FnDecl {
13151315
13161316 /// * `header_len`: The length of the function header and name. In other words, the number of
13171317 /// 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.
13191320 /// * `indent`: The number of spaces to indent each successive line with, if line-wrapping is
13201321 /// necessary.
13211322 pub ( crate ) fn full_print < ' a , ' tcx : ' a > (
@@ -1363,7 +1364,7 @@ impl clean::FnDecl {
13631364 }
13641365 } else {
13651366 if i > 0 {
1366- args. push_str ( "<br> " ) ;
1367+ args. push_str ( "\n " ) ;
13671368 }
13681369 if input. is_const {
13691370 args. push_str ( "const " ) ;
@@ -1389,7 +1390,7 @@ impl clean::FnDecl {
13891390 let mut args = args. into_inner ( ) ;
13901391
13911392 if self . c_variadic {
1392- args. push_str ( ",<br> ..." ) ;
1393+ args. push_str ( ",\n ..." ) ;
13931394 args_plain. push_str ( ", ..." ) ;
13941395 }
13951396
@@ -1399,24 +1400,20 @@ impl clean::FnDecl {
13991400
14001401 let declaration_len = header_len + args_plain. len ( ) + arrow_plain. len ( ) ;
14011402 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) ) ;
14041405 format ! (
14051406 "({pad}{args}{close}){arrow}" ,
14061407 pad = if self . inputs. values. is_empty( ) { "" } else { & full_pad } ,
1407- args = args. replace( "<br> " , & full_pad) ,
1408+ args = args. replace( "\n " , & full_pad) ,
14081409 close = close_pad,
14091410 arrow = arrow
14101411 )
14111412 } else {
1412- format ! ( "({args}){arrow}" , args = args. replace( "<br> " , " " ) , arrow = arrow)
1413+ format ! ( "({args}){arrow}" , args = args. replace( "\n " , " " ) , arrow = arrow)
14131414 } ;
14141415
1415- if f. alternate ( ) {
1416- write ! ( f, "{}" , output. replace( "<br>" , "\n " ) )
1417- } else {
1418- write ! ( f, "{}" , output)
1419- }
1416+ write ! ( f, "{}" , output)
14201417 }
14211418}
14221419
0 commit comments