@@ -251,9 +251,13 @@ fn format_args_expand(
251
251
}
252
252
for arg in & mut args {
253
253
// Remove `key =`.
254
- if matches ! ( arg. token_trees. get( 1 ) , Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Punct ( p) ) ) if p. char == '=' && p . spacing != tt :: Spacing :: Joint )
254
+ if matches ! ( arg. token_trees. get( 1 ) , Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Punct ( p) ) ) if p. char == '=' )
255
255
{
256
- arg. token_trees . drain ( ..2 ) ;
256
+ // but not with `==`
257
+ if !matches ! ( arg. token_trees. get( 2 ) , Some ( tt:: TokenTree :: Leaf ( tt:: Leaf :: Punct ( p) ) ) if p. char == '=' )
258
+ {
259
+ arg. token_trees . drain ( ..2 ) ;
260
+ }
257
261
}
258
262
}
259
263
let _format_string = args. remove ( 0 ) ;
@@ -357,6 +361,12 @@ fn unquote_str(lit: &tt::Literal) -> Option<String> {
357
361
token. value ( ) . map ( |it| it. into_owned ( ) )
358
362
}
359
363
364
+ fn unquote_char ( lit : & tt:: Literal ) -> Option < char > {
365
+ let lit = ast:: make:: tokens:: literal ( & lit. to_string ( ) ) ;
366
+ let token = ast:: Char :: cast ( lit) ?;
367
+ token. value ( )
368
+ }
369
+
360
370
fn unquote_byte_string ( lit : & tt:: Literal ) -> Option < Vec < u8 > > {
361
371
let lit = ast:: make:: tokens:: literal ( & lit. to_string ( ) ) ;
362
372
let token = ast:: ByteString :: cast ( lit) ?;
@@ -408,8 +418,12 @@ fn concat_expand(
408
418
// concat works with string and char literals, so remove any quotes.
409
419
// It also works with integer, float and boolean literals, so just use the rest
410
420
// as-is.
411
- let component = unquote_str ( it) . unwrap_or_else ( || it. text . to_string ( ) ) ;
412
- text. push_str ( & component) ;
421
+ if let Some ( c) = unquote_char ( it) {
422
+ text. push ( c) ;
423
+ } else {
424
+ let component = unquote_str ( it) . unwrap_or_else ( || it. text . to_string ( ) ) ;
425
+ text. push_str ( & component) ;
426
+ }
413
427
}
414
428
// handle boolean literals
415
429
tt:: TokenTree :: Leaf ( tt:: Leaf :: Ident ( id) )
0 commit comments