@@ -2559,29 +2559,38 @@ fn rewrite_fn_base(
2559
2559
}
2560
2560
2561
2561
// Comment between return type and the end of the decl.
2562
- let snippet_lo = fd. output . span ( ) . hi ( ) ;
2563
2562
if where_clause. predicates . is_empty ( ) {
2563
+ let snippet_lo = fd. output . span ( ) . hi ( ) ;
2564
2564
let snippet_hi = span. hi ( ) ;
2565
- let snippet = context. snippet ( mk_sp ( snippet_lo, snippet_hi) ) ;
2566
- // Try to preserve the layout of the original snippet.
2567
- let original_starts_with_newline = snippet
2568
- . find ( |c| c != ' ' )
2569
- . map_or ( false , |i| starts_with_newline ( & snippet[ i..] ) ) ;
2570
- let original_ends_with_newline = snippet
2571
- . rfind ( |c| c != ' ' )
2572
- . map_or ( false , |i| snippet[ i..] . ends_with ( '\n' ) ) ;
2573
- let snippet = snippet. trim ( ) ;
2574
- if !snippet. is_empty ( ) {
2575
- result. push ( if original_starts_with_newline {
2576
- '\n'
2577
- } else {
2578
- ' '
2579
- } ) ;
2580
- result. push_str ( snippet) ;
2581
- if original_ends_with_newline {
2582
- force_new_line_for_brace = true ;
2565
+
2566
+ let mut deal_snippet = |snippet : & str | {
2567
+ // Try to preserve the layout of the original snippet.
2568
+ let original_starts_with_newline = snippet
2569
+ . find ( |c| c != ' ' )
2570
+ . map_or ( false , |i| starts_with_newline ( & snippet[ i..] ) ) ;
2571
+ let original_ends_with_newline = snippet
2572
+ . rfind ( |c| c != ' ' )
2573
+ . map_or ( false , |i| snippet[ i..] . ends_with ( '\n' ) ) ;
2574
+ let snippet = snippet. trim ( ) ;
2575
+ if !snippet. is_empty ( ) {
2576
+ result. push ( if original_starts_with_newline {
2577
+ '\n'
2578
+ } else {
2579
+ ' '
2580
+ } ) ;
2581
+ result. push_str ( snippet) ;
2582
+ if original_ends_with_newline {
2583
+ force_new_line_for_brace = true ;
2584
+ }
2583
2585
}
2584
- }
2586
+ } ;
2587
+
2588
+ if context. config . version ( ) == Version :: Two && where_clause. has_where_token {
2589
+ deal_snippet ( context. snippet ( mk_sp ( snippet_lo, where_clause. span . lo ( ) ) ) ) ;
2590
+ deal_snippet ( context. snippet ( mk_sp ( where_clause. span . hi ( ) , snippet_hi) ) ) ;
2591
+ } else {
2592
+ deal_snippet ( context. snippet ( mk_sp ( snippet_lo, snippet_hi) ) ) ;
2593
+ } ;
2585
2594
}
2586
2595
}
2587
2596
0 commit comments