Commit 908cc43
authored
tracing: fix event macros with constant field names in the first position (#2883)
## Motivation
Const argumetns in `level!` macros do not work when in the first
position.
This also seems to have fixed #2748 where literals for fields names like
`info!("foo" = 2)` could not be used outside the `event!` macro.
Fixes #2837
Fixes #2738
## Solution
Previsously, `level!($(args:tt))` was forwarded to `event!(target: ...,
level: ..., { $(args:tt) })` but the added curly braces seem to have
prevented the `event` macro from correctly understanding the arguments
and it tried to pass them to `format!`.
With this change there may have some performance impact when expanding
the macros in most cases where the braces could have been added as it
will take one more step.
These are the two relevant `event!` blocks I believe, the new tests used
to expand to the first one (with empty fields), now they expand to the
latter:
```
(target: $target:expr, $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) => (
$crate::event!(
target: $target,
$lvl,
{ message = $crate::__macro_support::format_args!($($arg)+), $($fields)* }
)
);
(target: $target:expr, $lvl:expr, $($arg:tt)+ ) => (
$crate::event!(target: $target, $lvl, { $($arg)+ })
);
```1 parent 0e3577f commit 908cc43
3 files changed
+85
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1545 | 1545 | | |
1546 | 1546 | | |
1547 | 1547 | | |
1548 | | - | |
1549 | 1548 | | |
1550 | 1549 | | |
1551 | 1550 | | |
| |||
1822 | 1821 | | |
1823 | 1822 | | |
1824 | 1823 | | |
1825 | | - | |
1826 | 1824 | | |
1827 | 1825 | | |
1828 | 1826 | | |
| |||
2110 | 2108 | | |
2111 | 2109 | | |
2112 | 2110 | | |
2113 | | - | |
2114 | 2111 | | |
2115 | 2112 | | |
2116 | 2113 | | |
| |||
2391 | 2388 | | |
2392 | 2389 | | |
2393 | 2390 | | |
2394 | | - | |
2395 | 2391 | | |
2396 | 2392 | | |
2397 | 2393 | | |
| |||
2668 | 2664 | | |
2669 | 2665 | | |
2670 | 2666 | | |
2671 | | - | |
2672 | 2667 | | |
2673 | 2668 | | |
2674 | 2669 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
419 | 425 | | |
420 | 426 | | |
421 | 427 | | |
| |||
439 | 445 | | |
440 | 446 | | |
441 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
442 | 496 | | |
443 | 497 | | |
444 | 498 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
| 558 | + | |
| 559 | + | |
558 | 560 | | |
559 | 561 | | |
560 | 562 | | |
561 | 563 | | |
562 | 564 | | |
563 | 565 | | |
| 566 | + | |
564 | 567 | | |
565 | 568 | | |
566 | 569 | | |
| |||
579 | 582 | | |
580 | 583 | | |
581 | 584 | | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
582 | 588 | | |
583 | 589 | | |
584 | 590 | | |
| |||
615 | 621 | | |
616 | 622 | | |
617 | 623 | | |
| 624 | + | |
| 625 | + | |
618 | 626 | | |
619 | 627 | | |
620 | 628 | | |
621 | 629 | | |
622 | 630 | | |
623 | 631 | | |
| 632 | + | |
624 | 633 | | |
625 | 634 | | |
626 | 635 | | |
| |||
639 | 648 | | |
640 | 649 | | |
641 | 650 | | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
642 | 654 | | |
643 | 655 | | |
644 | 656 | | |
| |||
675 | 687 | | |
676 | 688 | | |
677 | 689 | | |
| 690 | + | |
| 691 | + | |
678 | 692 | | |
679 | 693 | | |
680 | 694 | | |
681 | 695 | | |
682 | 696 | | |
683 | 697 | | |
| 698 | + | |
684 | 699 | | |
685 | 700 | | |
686 | 701 | | |
| |||
699 | 714 | | |
700 | 715 | | |
701 | 716 | | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
702 | 720 | | |
703 | 721 | | |
704 | 722 | | |
| |||
735 | 753 | | |
736 | 754 | | |
737 | 755 | | |
| 756 | + | |
| 757 | + | |
738 | 758 | | |
739 | 759 | | |
740 | 760 | | |
741 | 761 | | |
742 | 762 | | |
743 | 763 | | |
| 764 | + | |
744 | 765 | | |
745 | 766 | | |
746 | 767 | | |
| |||
759 | 780 | | |
760 | 781 | | |
761 | 782 | | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
762 | 786 | | |
763 | 787 | | |
764 | 788 | | |
| |||
795 | 819 | | |
796 | 820 | | |
797 | 821 | | |
| 822 | + | |
| 823 | + | |
798 | 824 | | |
799 | 825 | | |
800 | 826 | | |
801 | 827 | | |
802 | 828 | | |
803 | 829 | | |
| 830 | + | |
804 | 831 | | |
805 | 832 | | |
806 | | - | |
| 833 | + | |
807 | 834 | | |
808 | 835 | | |
809 | 836 | | |
| |||
819 | 846 | | |
820 | 847 | | |
821 | 848 | | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
822 | 852 | | |
823 | 853 | | |
824 | 854 | | |
| |||
0 commit comments