@@ -79,9 +79,6 @@ pub fn parse_format_exprs(input: &str) -> Result<(String, Vec<Arg>), ()> {
7979 state = State :: MaybeIncorrect ;
8080 }
8181 ( State :: NotArg , _) => {
82- if matches ! ( chr, '\\' | '$' ) {
83- output. push ( '\\' ) ;
84- }
8582 output. push ( chr) ;
8683 }
8784 ( State :: MaybeIncorrect , '}' ) => {
@@ -110,9 +107,6 @@ pub fn parse_format_exprs(input: &str) -> Result<(String, Vec<Arg>), ()> {
110107 state = State :: FormatOpts ;
111108 }
112109 ( State :: MaybeArg , _) => {
113- if matches ! ( chr, '\\' | '$' ) {
114- current_expr. push ( '\\' ) ;
115- }
116110 current_expr. push ( chr) ;
117111
118112 // While Rust uses the unicode sets of XID_start and XID_continue for Identifiers
@@ -172,19 +166,13 @@ pub fn parse_format_exprs(input: &str) -> Result<(String, Vec<Arg>), ()> {
172166 state = State :: Expr ;
173167 }
174168
175- if matches ! ( chr, '\\' | '$' ) {
176- current_expr. push ( '\\' ) ;
177- }
178169 current_expr. push ( chr) ;
179170 }
180171 ( State :: FormatOpts , '}' ) => {
181172 output. push ( chr) ;
182173 state = State :: NotArg ;
183174 }
184175 ( State :: FormatOpts , _) => {
185- if matches ! ( chr, '\\' | '$' ) {
186- output. push ( '\\' ) ;
187- }
188176 output. push ( chr) ;
189177 }
190178 }
@@ -217,15 +205,15 @@ mod tests {
217205 fn format_str_parser ( ) {
218206 let test_vector = & [
219207 ( "no expressions" , expect ! [ [ "no expressions" ] ] ) ,
220- ( r"no expressions with \$0$1" , expect ! [ r"no expressions with \\\$0\ $1" ] ) ,
208+ ( r"no expressions with \$0$1" , expect ! [ r"no expressions with \$0 $1" ] ) ,
221209 ( "{expr} is {2 + 2}" , expect ! [ [ "{expr} is {}; 2 + 2" ] ] ) ,
222210 ( "{expr:?}" , expect ! [ [ "{expr:?}" ] ] ) ,
223- ( "{expr:1$}" , expect ! [ [ r"{expr:1\ $}" ] ] ) ,
224- ( "{:1$}" , expect ! [ [ r"{:1\ $}; $1" ] ] ) ,
225- ( "{:>padding$}" , expect ! [ [ r"{:>padding\ $}; $1" ] ] ) ,
211+ ( "{expr:1$}" , expect ! [ [ r"{expr:1$}" ] ] ) ,
212+ ( "{:1$}" , expect ! [ [ r"{:1$}; $1" ] ] ) ,
213+ ( "{:>padding$}" , expect ! [ [ r"{:>padding$}; $1" ] ] ) ,
226214 ( "{}, {}, {0}" , expect ! [ [ r"{}, {}, {0}; $1, $2" ] ] ) ,
227215 ( "{}, {}, {0:b}" , expect ! [ [ r"{}, {}, {0:b}; $1, $2" ] ] ) ,
228- ( "{$0}" , expect ! [ [ r"{}; \ $0" ] ] ) ,
216+ ( "{$0}" , expect ! [ [ r"{}; $0" ] ] ) ,
229217 ( "{malformed" , expect ! [ [ "-" ] ] ) ,
230218 ( "malformed}" , expect ! [ [ "-" ] ] ) ,
231219 ( "{{correct" , expect ! [ [ "{{correct" ] ] ) ,
0 commit comments