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