@@ -6,7 +6,6 @@ use syntax::{ast, visit};
6
6
7
7
use crate :: attr:: * ;
8
8
use crate :: comment:: { rewrite_comment, CodeCharKind , CommentCodeSlices } ;
9
- use crate :: config:: Version ;
10
9
use crate :: config:: { BraceStyle , Config } ;
11
10
use crate :: coverage:: transform_missing_snippet;
12
11
use crate :: items:: {
@@ -263,60 +262,32 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
263
262
264
263
let mut comment_shape =
265
264
Shape :: indented ( self . block_indent , config) . comment ( config) ;
266
- if self . config . version ( ) == Version :: Two && comment_on_same_line {
267
- self . push_str ( " " ) ;
268
- // put the first line of the comment on the same line as the
269
- // block's last line
270
- match sub_slice. find ( "\n " ) {
271
- None => {
272
- self . push_str ( & sub_slice) ;
273
- }
274
- Some ( offset) if offset + 1 == sub_slice. len ( ) => {
275
- self . push_str ( & sub_slice[ ..offset] ) ;
276
- }
277
- Some ( offset) => {
278
- let first_line = & sub_slice[ ..offset] ;
279
- self . push_str ( first_line) ;
280
- self . push_str ( & self . block_indent . to_string_with_newline ( config) ) ;
281
-
282
- // put the other lines below it, shaping it as needed
283
- 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) ,
289
- }
290
- }
265
+ if comment_on_same_line {
266
+ // 1 = a space before `//`
267
+ let offset_len = 1 + last_line_width ( & self . buffer )
268
+ . saturating_sub ( self . block_indent . width ( ) ) ;
269
+ match comment_shape
270
+ . visual_indent ( offset_len)
271
+ . sub_width ( offset_len)
272
+ {
273
+ Some ( shp) => comment_shape = shp,
274
+ None => comment_on_same_line = false ,
291
275
}
276
+ } ;
277
+
278
+ if comment_on_same_line {
279
+ self . push_str ( " " ) ;
292
280
} else {
293
- if comment_on_same_line {
294
- // 1 = a space before `//`
295
- let offset_len = 1 + last_line_width ( & self . buffer )
296
- . saturating_sub ( self . block_indent . width ( ) ) ;
297
- match comment_shape
298
- . visual_indent ( offset_len)
299
- . sub_width ( offset_len)
300
- {
301
- Some ( shp) => comment_shape = shp,
302
- None => comment_on_same_line = false ,
303
- }
304
- } ;
305
-
306
- if comment_on_same_line {
307
- self . push_str ( " " ) ;
308
- } else {
309
- if count_newlines ( snippet_in_between) >= 2 || extra_newline {
310
- self . push_str ( "\n " ) ;
311
- }
312
- self . push_str ( & self . block_indent . to_string_with_newline ( config) ) ;
281
+ if count_newlines ( snippet_in_between) >= 2 || extra_newline {
282
+ self . push_str ( "\n " ) ;
313
283
}
284
+ self . push_str ( & self . block_indent . to_string_with_newline ( config) ) ;
285
+ }
314
286
315
- let comment_str = rewrite_comment ( & sub_slice, false , comment_shape, config) ;
316
- match comment_str {
317
- Some ( ref s) => self . push_str ( s) ,
318
- None => self . push_str ( & sub_slice) ,
319
- }
287
+ let comment_str = rewrite_comment ( & sub_slice, false , comment_shape, config) ;
288
+ match comment_str {
289
+ Some ( ref s) => self . push_str ( s) ,
290
+ None => self . push_str ( & sub_slice) ,
320
291
}
321
292
}
322
293
CodeCharKind :: Normal if skip_normal ( & sub_slice) => {
0 commit comments