@@ -248,7 +248,6 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
248248
249249 for ( kind, offset, sub_slice) in CommentCodeSlices :: new ( self . snippet ( span) ) {
250250 let sub_slice = transform_missing_snippet ( config, sub_slice) ;
251-
252251 debug ! ( "close_block: {:?} {:?} {:?}" , kind, offset, sub_slice) ;
253252
254253 match kind {
@@ -277,19 +276,24 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
277276 Some ( offset) => {
278277 let first_line = & sub_slice[ ..offset] ;
279278 self . push_str ( first_line) ;
280- self . push_str ( & self . block_indent . to_string_with_newline ( config) ) ;
281279
282280 // put the other lines below it, shaping it as needed
283281 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+ }
289292 }
290293 }
291294 }
292295 } else {
296+ let sub_slice = sub_slice. trim ( ) ;
293297 if comment_on_same_line {
294298 // 1 = a space before `//`
295299 let offset_len = 1 + last_line_width ( & self . buffer )
0 commit comments