@@ -79,9 +79,6 @@ pub fn parse_format_exprs(input: &str) -> Result<(String, Vec<Arg>), ()> {
79
79
state = State :: MaybeIncorrect ;
80
80
}
81
81
( State :: NotArg , _) => {
82
- if matches ! ( chr, '\\' | '$' ) {
83
- output. push ( '\\' ) ;
84
- }
85
82
output. push ( chr) ;
86
83
}
87
84
( State :: MaybeIncorrect , '}' ) => {
@@ -110,9 +107,6 @@ pub fn parse_format_exprs(input: &str) -> Result<(String, Vec<Arg>), ()> {
110
107
state = State :: FormatOpts ;
111
108
}
112
109
( State :: MaybeArg , _) => {
113
- if matches ! ( chr, '\\' | '$' ) {
114
- current_expr. push ( '\\' ) ;
115
- }
116
110
current_expr. push ( chr) ;
117
111
118
112
// 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>), ()> {
172
166
state = State :: Expr ;
173
167
}
174
168
175
- if matches ! ( chr, '\\' | '$' ) {
176
- current_expr. push ( '\\' ) ;
177
- }
178
169
current_expr. push ( chr) ;
179
170
}
180
171
( State :: FormatOpts , '}' ) => {
181
172
output. push ( chr) ;
182
173
state = State :: NotArg ;
183
174
}
184
175
( State :: FormatOpts , _) => {
185
- if matches ! ( chr, '\\' | '$' ) {
186
- output. push ( '\\' ) ;
187
- }
188
176
output. push ( chr) ;
189
177
}
190
178
}
@@ -217,15 +205,15 @@ mod tests {
217
205
fn format_str_parser ( ) {
218
206
let test_vector = & [
219
207
( "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" ] ) ,
221
209
( "{expr} is {2 + 2}" , expect ! [ [ "{expr} is {}; 2 + 2" ] ] ) ,
222
210
( "{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" ] ] ) ,
226
214
( "{}, {}, {0}" , expect ! [ [ r"{}, {}, {0}; $1, $2" ] ] ) ,
227
215
( "{}, {}, {0:b}" , expect ! [ [ r"{}, {}, {0:b}; $1, $2" ] ] ) ,
228
- ( "{$0}" , expect ! [ [ r"{}; \ $0" ] ] ) ,
216
+ ( "{$0}" , expect ! [ [ r"{}; $0" ] ] ) ,
229
217
( "{malformed" , expect ! [ [ "-" ] ] ) ,
230
218
( "malformed}" , expect ! [ [ "-" ] ] ) ,
231
219
( "{{correct" , expect ! [ [ "{{correct" ] ] ) ,
0 commit comments