File tree 3 files changed +25
-14
lines changed
compiler/rustc_parse_format/src
3 files changed +25
-14
lines changed Original file line number Diff line number Diff line change @@ -735,25 +735,24 @@ fn find_skips_from_snippet(
735
735
} ;
736
736
737
737
fn find_skips ( snippet : & str , is_raw : bool ) -> Vec < usize > {
738
- let mut eat_ws = false ;
739
738
let mut s = snippet. char_indices ( ) . peekable ( ) ;
740
739
let mut skips = vec ! [ ] ;
741
740
while let Some ( ( pos, c) ) = s. next ( ) {
742
741
match ( c, s. peek ( ) ) {
743
742
// skip whitespace and empty lines ending in '\\'
744
743
( '\\' , Some ( ( next_pos, '\n' ) ) ) if !is_raw => {
745
- eat_ws = true ;
746
744
skips. push ( pos) ;
747
745
skips. push ( * next_pos) ;
748
746
let _ = s. next ( ) ;
749
- }
750
- ( '\\' , Some ( ( next_pos, '\n' | 'n' | 't' ) ) ) if eat_ws => {
751
- skips. push ( pos) ;
752
- skips. push ( * next_pos) ;
753
- let _ = s. next ( ) ;
754
- }
755
- ( ' ' | '\n' | '\t' , _) if eat_ws => {
756
- skips. push ( pos) ;
747
+
748
+ while let Some ( ( pos, c) ) = s. peek ( ) {
749
+ if matches ! ( c, ' ' | '\n' | '\t' ) {
750
+ skips. push ( * pos) ;
751
+ let _ = s. next ( ) ;
752
+ } else {
753
+ break ;
754
+ }
755
+ }
757
756
}
758
757
( '\\' , Some ( ( next_pos, 'n' | 't' | 'r' | '0' | '\\' | '\'' | '\"' ) ) ) => {
759
758
skips. push ( * next_pos) ;
@@ -804,10 +803,6 @@ fn find_skips_from_snippet(
804
803
}
805
804
}
806
805
}
807
- _ if eat_ws => {
808
- // `take_while(|c| c.is_whitespace())`
809
- eat_ws = false ;
810
- }
811
806
_ => { }
812
807
}
813
808
}
Original file line number Diff line number Diff line change
1
+ // check-fail
2
+
3
+ fn main ( ) {
4
+ println ! (
5
+ "\
6
+ \n {} │", //~ ERROR: 1 positional argument in format string, but no arguments were given
7
+ ) ;
8
+ }
Original file line number Diff line number Diff line change
1
+ error: 1 positional argument in format string, but no arguments were given
2
+ --> $DIR/issue-83340.rs:6:4
3
+ |
4
+ LL | \n {} │",
5
+ | ^^
6
+
7
+ error: aborting due to previous error
8
+
You can’t perform that action at this time.
0 commit comments