diff options
author | Jonas Schievink <[email protected]> | 2020-12-15 19:33:05 +0000 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2020-12-15 19:33:05 +0000 |
commit | b238ddd21adf9910769522a21e31c2e14f664396 (patch) | |
tree | 219749056bcef5cd35cfc94826108c4f955b1c8b /crates/hir_def/src/nameres/tests | |
parent | c31c3246a8c87a3639623c30b692a57e728bb046 (diff) |
Make macro def krate mandatory
Refactors builtin derive support to go through proper name resolution
Diffstat (limited to 'crates/hir_def/src/nameres/tests')
-rw-r--r-- | crates/hir_def/src/nameres/tests/macros.rs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/crates/hir_def/src/nameres/tests/macros.rs b/crates/hir_def/src/nameres/tests/macros.rs index 305fca0f9..6fe2ee78a 100644 --- a/crates/hir_def/src/nameres/tests/macros.rs +++ b/crates/hir_def/src/nameres/tests/macros.rs | |||
@@ -633,15 +633,44 @@ pub struct bar; | |||
633 | fn expand_derive() { | 633 | fn expand_derive() { |
634 | let map = compute_crate_def_map( | 634 | let map = compute_crate_def_map( |
635 | " | 635 | " |
636 | //- /main.rs | 636 | //- /main.rs crate:main deps:core |
637 | use core::*; | ||
638 | |||
637 | #[derive(Copy, Clone)] | 639 | #[derive(Copy, Clone)] |
638 | struct Foo; | 640 | struct Foo; |
641 | |||
642 | //- /core.rs crate:core | ||
643 | #[rustc_builtin_macro] | ||
644 | pub macro Copy {} | ||
645 | |||
646 | #[rustc_builtin_macro] | ||
647 | pub macro Clone {} | ||
639 | ", | 648 | ", |
640 | ); | 649 | ); |
641 | assert_eq!(map.modules[map.root].scope.impls().len(), 2); | 650 | assert_eq!(map.modules[map.root].scope.impls().len(), 2); |
642 | } | 651 | } |
643 | 652 | ||
644 | #[test] | 653 | #[test] |
654 | fn resolve_builtin_derive() { | ||
655 | check( | ||
656 | r#" | ||
657 | //- /main.rs crate:main deps:core | ||
658 | use core::*; | ||
659 | |||
660 | //- /core.rs crate:core | ||
661 | #[rustc_builtin_macro] | ||
662 | pub macro Clone {} | ||
663 | |||
664 | pub trait Clone {} | ||
665 | "#, | ||
666 | expect![[r#" | ||
667 | crate | ||
668 | Clone: t m | ||
669 | "#]], | ||
670 | ); | ||
671 | } | ||
672 | |||
673 | #[test] | ||
645 | fn macro_expansion_overflow() { | 674 | fn macro_expansion_overflow() { |
646 | mark::check!(macro_expansion_overflow); | 675 | mark::check!(macro_expansion_overflow); |
647 | check( | 676 | check( |