Commit 57b3c85
committed
Extend external_derive to cover proc-macro-generated impls
Proc-macro crates such as serde do not emit #[automatically_derived] on
the impls they generate. As a result, #[verifier::external_derive] had no
effect on serde-derived Serialize/Deserialize impls (issues #1575, #1577,
#1956): the gate in get_attributes_for_automatic_derive returned None
immediately for any impl lacking that attribute.
The fix checks span.from_expansion() as a secondary signal. When an impl
is macro-expanded but not #[automatically_derived], and the self type has
#[verifier::external_derive] (with AllExternal or a matching trait name),
the impl is now marked external. If the type has no external_derive
annotation at all, macro-expanded impls fall through to the normal
classification path unchanged, preserving existing behavior.
Tests added in rust_verify_test/tests/std.rs simulate proc-macro derives
with macro_rules! (which produces macro-expanded impls without
#[automatically_derived]) and verify that external_derive AllExternal and
SomeExternal(TraitName) both suppress verification of the generated impl.1 parent 9e00c04 commit 57b3c85
2 files changed
Lines changed: 102 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
646 | 646 | | |
647 | 647 | | |
648 | 648 | | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
649 | 654 | | |
650 | 655 | | |
651 | 656 | | |
| |||
663 | 668 | | |
664 | 669 | | |
665 | 670 | | |
666 | | - | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
667 | 676 | | |
668 | 677 | | |
669 | 678 | | |
| |||
679 | 688 | | |
680 | 689 | | |
681 | 690 | | |
682 | | - | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
683 | 694 | | |
684 | 695 | | |
685 | 696 | | |
| |||
689 | 700 | | |
690 | 701 | | |
691 | 702 | | |
692 | | - | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
693 | 706 | | |
694 | 707 | | |
695 | 708 | | |
696 | 709 | | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
697 | 722 | | |
698 | 723 | | |
699 | 724 | | |
| |||
721 | 746 | | |
722 | 747 | | |
723 | 748 | | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
724 | 755 | | |
725 | 756 | | |
726 | 757 | | |
| |||
737 | 768 | | |
738 | 769 | | |
739 | 770 | | |
740 | | - | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
741 | 774 | | |
742 | 775 | | |
743 | 776 | | |
744 | 777 | | |
745 | | - | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
746 | 781 | | |
747 | 782 | | |
748 | 783 | | |
749 | 784 | | |
750 | | - | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
751 | 788 | | |
752 | 789 | | |
753 | 790 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
603 | 603 | | |
604 | 604 | | |
605 | 605 | | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
606 | 665 | | |
607 | 666 | | |
608 | 667 | | |
| |||
0 commit comments