1 //! Tests for user-defined procedural macros.
3 //! Note `//- proc_macros: identity` fixture metas in tests -- we don't use real
4 //! proc-macros here, as that would be slow. Instead, we use several hard-coded
6 use expect_test::expect;
8 use crate::macro_expansion_tests::check;
11 fn attribute_macro_attr_censoring() {
12 cov_mark::check!(attribute_macro_attr_censoring);
15 //- proc_macros: identity
16 #[attr1] #[proc_macros::identity] #[attr2]
20 #[attr1] #[proc_macros::identity] #[attr2]
24 #[attr2] struct S;"##]],
29 fn derive_censoring() {
30 cov_mark::check!(derive_censoring);
33 //- proc_macros: derive_identity
37 #[derive(proc_macros::DeriveIdentity)]
45 #[derive(proc_macros::DeriveIdentity)]
52 #[attr2] struct S;"##]],
57 fn attribute_macro_syntax_completion_1() {
58 // this is just the case where the input is actually valid
61 //- proc_macros: identity_when_valid
62 #[proc_macros::identity_when_valid]
63 fn foo() { bar.baz(); blub }
66 #[proc_macros::identity_when_valid]
67 fn foo() { bar.baz(); blub }
77 fn attribute_macro_syntax_completion_2() {
78 // common case of dot completion while typing
81 //- proc_macros: identity_when_valid
82 #[proc_macros::identity_when_valid]
83 fn foo() { bar.; blub }
86 #[proc_macros::identity_when_valid]
87 fn foo() { bar.; blub }