@@ -516,7 +516,6 @@ fn format_lines(
516
516
config : & Config ,
517
517
report : & FormatReport ,
518
518
) {
519
- let mut trims = vec ! [ ] ;
520
519
let mut last_was_space = false ;
521
520
let mut line_len = 0 ;
522
521
let mut cur_line = 1 ;
@@ -565,8 +564,15 @@ fn format_lines(
565
564
// Check for (and record) trailing whitespace.
566
565
if last_was_space {
567
566
if should_report_error ( config, kind, is_string, & ErrorKind :: TrailingWhitespace )
567
+ && !is_skipped_line ( cur_line, skipped_range)
568
568
{
569
- trims. push ( ( cur_line, kind, line_buffer. clone ( ) ) ) ;
569
+ errors. push ( FormattingError {
570
+ line : cur_line,
571
+ kind : ErrorKind :: TrailingWhitespace ,
572
+ is_comment : kind. is_comment ( ) ,
573
+ is_string : kind. is_string ( ) ,
574
+ line_buffer : line_buffer. clone ( ) ,
575
+ } ) ;
570
576
}
571
577
line_len -= 1 ;
572
578
}
@@ -611,18 +617,6 @@ fn format_lines(
611
617
text. truncate ( line) ;
612
618
}
613
619
614
- for & ( l, kind, ref b) in & trims {
615
- if !is_skipped_line ( l, skipped_range) {
616
- errors. push ( FormattingError {
617
- line : l,
618
- kind : ErrorKind :: TrailingWhitespace ,
619
- is_comment : kind. is_comment ( ) ,
620
- is_string : kind. is_string ( ) ,
621
- line_buffer : b. clone ( ) ,
622
- } ) ;
623
- }
624
- }
625
-
626
620
report. append ( name. clone ( ) , errors) ;
627
621
}
628
622
0 commit comments