@@ -248,7 +248,6 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
248
248
249
249
for ( kind, offset, sub_slice) in CommentCodeSlices :: new ( self . snippet ( span) ) {
250
250
let sub_slice = transform_missing_snippet ( config, sub_slice) ;
251
-
252
251
debug ! ( "close_block: {:?} {:?} {:?}" , kind, offset, sub_slice) ;
253
252
254
253
match kind {
@@ -277,19 +276,24 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
277
276
Some ( offset) => {
278
277
let first_line = & sub_slice[ ..offset] ;
279
278
self . push_str ( first_line) ;
280
- self . push_str ( & self . block_indent . to_string_with_newline ( config) ) ;
281
279
282
280
// put the other lines below it, shaping it as needed
283
281
let other_lines = & sub_slice[ offset + 1 ..] ;
284
- let comment_str =
285
- rewrite_comment ( other_lines, false , comment_shape, config) ;
286
- match comment_str {
287
- Some ( ref s) => self . push_str ( s) ,
288
- None => self . push_str ( other_lines) ,
282
+ if !other_lines. trim ( ) . is_empty ( ) {
283
+ self . push_str (
284
+ & self . block_indent . to_string_with_newline ( config) ,
285
+ ) ;
286
+ let comment_str =
287
+ rewrite_comment ( other_lines, false , comment_shape, config) ;
288
+ match comment_str {
289
+ Some ( ref s) => self . push_str ( s) ,
290
+ None => self . push_str ( other_lines) ,
291
+ }
289
292
}
290
293
}
291
294
}
292
295
} else {
296
+ let sub_slice = sub_slice. trim ( ) ;
293
297
if comment_on_same_line {
294
298
// 1 = a space before `//`
295
299
let offset_len = 1 + last_line_width ( & self . buffer )
0 commit comments