Commit fb795ec
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 2fbad8a commit fb795ec
2 files changed
Lines changed: 102 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
645 | 645 | | |
646 | 646 | | |
647 | 647 | | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
648 | 653 | | |
649 | 654 | | |
650 | 655 | | |
| |||
660 | 665 | | |
661 | 666 | | |
662 | 667 | | |
663 | | - | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
664 | 673 | | |
665 | 674 | | |
666 | 675 | | |
| |||
676 | 685 | | |
677 | 686 | | |
678 | 687 | | |
679 | | - | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
680 | 691 | | |
681 | 692 | | |
682 | 693 | | |
| |||
686 | 697 | | |
687 | 698 | | |
688 | 699 | | |
689 | | - | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
690 | 703 | | |
691 | 704 | | |
692 | 705 | | |
693 | 706 | | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
694 | 719 | | |
695 | 720 | | |
696 | 721 | | |
| |||
718 | 743 | | |
719 | 744 | | |
720 | 745 | | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
721 | 752 | | |
722 | 753 | | |
723 | 754 | | |
| |||
734 | 765 | | |
735 | 766 | | |
736 | 767 | | |
737 | | - | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
738 | 771 | | |
739 | 772 | | |
740 | 773 | | |
741 | 774 | | |
742 | | - | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
743 | 778 | | |
744 | 779 | | |
745 | 780 | | |
746 | 781 | | |
747 | | - | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
748 | 785 | | |
749 | 786 | | |
750 | 787 | | |
| |||
| 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