@@ -3,7 +3,6 @@ use syntax::source_map::{BytePos, Pos, Span};
3
3
use crate :: comment:: { is_last_comment_block, rewrite_comment, CodeCharKind , CommentCodeSlices } ;
4
4
use crate :: config:: file_lines:: FileLines ;
5
5
use crate :: config:: FileName ;
6
- use crate :: config:: Version ;
7
6
use crate :: coverage:: transform_missing_snippet;
8
7
use crate :: shape:: { Indent , Shape } ;
9
8
use crate :: source_map:: LineRangeUtils ;
@@ -236,7 +235,6 @@ impl<'a> FmtVisitor<'a> {
236
235
. next ( ) ;
237
236
238
237
let fix_indent = last_char. map_or ( true , |rev_c| [ '{' , '\n' ] . contains ( & rev_c) ) ;
239
- let mut on_same_line = false ;
240
238
241
239
let comment_indent = if fix_indent {
242
240
if let Some ( '{' ) = last_char {
@@ -245,13 +243,6 @@ impl<'a> FmtVisitor<'a> {
245
243
let indent_str = self . block_indent . to_string ( self . config ) ;
246
244
self . push_str ( & indent_str) ;
247
245
self . block_indent
248
- } else if self . config . version ( ) == Version :: Two && !snippet. starts_with ( '\n' ) {
249
- // The comment appears on the same line as the previous formatted code.
250
- // Assuming that comment is logically associated with that code, we want to keep it on
251
- // the same level and avoid mixing it with possible other comment.
252
- on_same_line = true ;
253
- self . push_str ( " " ) ;
254
- self . block_indent
255
246
} else {
256
247
self . push_str ( " " ) ;
257
248
Indent :: from_width ( self . config , last_line_width ( & self . buffer ) )
@@ -262,34 +253,9 @@ impl<'a> FmtVisitor<'a> {
262
253
self . config . max_width ( ) - self . block_indent . width ( ) ,
263
254
) ;
264
255
let comment_shape = Shape :: legacy ( comment_width, comment_indent) ;
265
-
266
- if on_same_line {
267
- match subslice. find ( "\n " ) {
268
- None => {
269
- self . push_str ( subslice) ;
270
- }
271
- Some ( offset) if offset + 1 == subslice. len ( ) => {
272
- self . push_str ( & subslice[ ..offset] ) ;
273
- }
274
- Some ( offset) => {
275
- // keep first line as is: if it were too long and wrapped, it may get mixed
276
- // with the other lines.
277
- let first_line = & subslice[ ..offset] ;
278
- self . push_str ( first_line) ;
279
- self . push_str ( & comment_indent. to_string_with_newline ( self . config ) ) ;
280
-
281
- let other_lines = & subslice[ offset + 1 ..] ;
282
- let comment_str =
283
- rewrite_comment ( other_lines, false , comment_shape, self . config )
284
- . unwrap_or_else ( || String :: from ( other_lines) ) ;
285
- self . push_str ( & comment_str) ;
286
- }
287
- }
288
- } else {
289
- let comment_str = rewrite_comment ( subslice, false , comment_shape, self . config )
290
- . unwrap_or_else ( || String :: from ( subslice) ) ;
291
- self . push_str ( & comment_str) ;
292
- }
256
+ let comment_str = rewrite_comment ( subslice, false , comment_shape, self . config )
257
+ . unwrap_or_else ( || String :: from ( subslice) ) ;
258
+ self . push_str ( & comment_str) ;
293
259
294
260
status. last_wspace = None ;
295
261
status. line_start = offset + subslice. len ( ) ;
0 commit comments