@@ -868,20 +868,16 @@ pub(crate) fn format_impl(
868
868
. first ( )
869
869
. map ( |a| a. span . lo ( ) )
870
870
. or_else ( || items. first ( ) . map ( |i| i. span ( ) . lo ( ) ) ) ;
871
- let opening_nls = visitor. advance_to_first_block_item ( first_non_ws) ;
871
+ if let Some ( opening_nls) = visitor. advance_to_first_block_item ( first_non_ws) {
872
+ result. push_str ( & opening_nls) ;
873
+ }
872
874
873
875
visitor. visit_attrs ( & item. attrs , ast:: AttrStyle :: Inner ) ;
874
876
visitor. visit_impl_items ( items) ;
875
877
876
878
visitor. format_missing ( item. span . hi ( ) - BytePos ( 1 ) ) ;
877
879
878
- let inner_indent_str = if let Some ( opening_nls) = opening_nls {
879
- result. push_str ( & opening_nls) ;
880
- visitor. block_indent . to_string ( context. config )
881
- } else {
882
- visitor. block_indent . to_string_with_newline ( context. config )
883
- } ;
884
-
880
+ let inner_indent_str = visitor. block_indent . to_string_with_newline ( context. config ) ;
885
881
let outer_indent_str = offset. block_only ( ) . to_string_with_newline ( context. config ) ;
886
882
887
883
result. push_str ( & inner_indent_str) ;
@@ -1235,21 +1231,19 @@ pub(crate) fn format_trait(
1235
1231
visitor. block_indent = offset. block_only ( ) . block_indent ( context. config ) ;
1236
1232
visitor. last_pos = block_span. lo ( ) + BytePos ( open_pos as u32 ) ;
1237
1233
1238
- let opening_nls =
1239
- visitor. advance_to_first_block_item ( trait_items. first ( ) . map ( |i| i. span ( ) . lo ( ) ) ) ;
1234
+ if let Some ( opening_nls) =
1235
+ visitor. advance_to_first_block_item ( trait_items. first ( ) . map ( |i| i. span ( ) . lo ( ) ) )
1236
+ {
1237
+ result. push_str ( & opening_nls) ;
1238
+ }
1240
1239
1241
1240
for item in trait_items {
1242
1241
visitor. visit_trait_item ( item) ;
1243
1242
}
1244
1243
1245
1244
visitor. format_missing ( item. span . hi ( ) - BytePos ( 1 ) ) ;
1246
1245
1247
- let inner_indent_str = if let Some ( opening_nls) = opening_nls {
1248
- result. push_str ( & opening_nls) ;
1249
- visitor. block_indent . to_string ( context. config )
1250
- } else {
1251
- visitor. block_indent . to_string_with_newline ( context. config )
1252
- } ;
1246
+ let inner_indent_str = visitor. block_indent . to_string_with_newline ( context. config ) ;
1253
1247
1254
1248
result. push_str ( & inner_indent_str) ;
1255
1249
result. push_str ( visitor. buffer . trim ( ) ) ;
0 commit comments