File tree Expand file tree Collapse file tree 3 files changed +25
-14
lines changed
compiler/rustc_parse_format/src Expand file tree Collapse file tree 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(
735735 } ;
736736
737737 fn find_skips ( snippet : & str , is_raw : bool ) -> Vec < usize > {
738- let mut eat_ws = false ;
739738 let mut s = snippet. char_indices ( ) . peekable ( ) ;
740739 let mut skips = vec ! [ ] ;
741740 while let Some ( ( pos, c) ) = s. next ( ) {
742741 match ( c, s. peek ( ) ) {
743742 // skip whitespace and empty lines ending in '\\'
744743 ( '\\' , Some ( ( next_pos, '\n' ) ) ) if !is_raw => {
745- eat_ws = true ;
746744 skips. push ( pos) ;
747745 skips. push ( * next_pos) ;
748746 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+ }
757756 }
758757 ( '\\' , Some ( ( next_pos, 'n' | 't' | 'r' | '0' | '\\' | '\'' | '\"' ) ) ) => {
759758 skips. push ( * next_pos) ;
@@ -804,10 +803,6 @@ fn find_skips_from_snippet(
804803 }
805804 }
806805 }
807- _ if eat_ws => {
808- // `take_while(|c| c.is_whitespace())`
809- eat_ws = false ;
810- }
811806 _ => { }
812807 }
813808 }
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