]>
Commit | Line | Data |
---|---|---|
a1dfa0c6 | 1 | // force-host |
8faf50e0 XL |
2 | // no-prefer-dynamic |
3 | ||
8faf50e0 XL |
4 | #![crate_type = "proc-macro"] |
5 | ||
6 | extern crate proc_macro; | |
7 | use proc_macro::*; | |
8 | ||
9 | #[proc_macro] | |
10 | pub fn my_macro(input: TokenStream) -> TokenStream { | |
11 | input | |
12 | } | |
13 | ||
14 | #[proc_macro_attribute] | |
15 | pub fn my_macro_attr(input: TokenStream, _: TokenStream) -> TokenStream { | |
16 | input | |
17 | } | |
18 | ||
19 | #[proc_macro_derive(MyTrait)] | |
20 | pub fn my_macro_derive(input: TokenStream) -> TokenStream { | |
21 | input | |
22 | } | |
23 | ||
24 | fn check_bang1() { | |
25 | my_macro!(); //~ ERROR can't use a procedural macro from the same crate that defines it | |
26 | } | |
27 | fn check_bang2() { | |
e1599b0c | 28 | my_macro_attr!(); //~ ERROR cannot find macro `my_macro_attr` in this scope |
416331ca XL |
29 | crate::my_macro_attr!(); //~ ERROR can't use a procedural macro from the same crate that defines |
30 | //~| ERROR expected macro, found attribute macro `crate::my_macro_attr` | |
8faf50e0 XL |
31 | } |
32 | fn check_bang3() { | |
e1599b0c | 33 | MyTrait!(); //~ ERROR cannot find macro `MyTrait` in this scope |
416331ca XL |
34 | crate::MyTrait!(); //~ ERROR can't use a procedural macro from the same crate that defines it |
35 | //~| ERROR expected macro, found derive macro `crate::MyTrait` | |
8faf50e0 XL |
36 | } |
37 | ||
e1599b0c | 38 | #[my_macro] //~ ERROR cannot find attribute `my_macro` in this scope |
416331ca XL |
39 | #[crate::my_macro] //~ ERROR can't use a procedural macro from the same crate that defines it |
40 | //~| ERROR expected attribute, found macro `crate::my_macro` | |
8faf50e0 XL |
41 | fn check_attr1() {} |
42 | #[my_macro_attr] //~ ERROR can't use a procedural macro from the same crate that defines it | |
43 | fn check_attr2() {} | |
44 | #[MyTrait] //~ ERROR can't use a procedural macro from the same crate that defines it | |
416331ca | 45 | //~| ERROR expected attribute, found derive macro `MyTrait` |
8faf50e0 XL |
46 | fn check_attr3() {} |
47 | ||
416331ca | 48 | #[derive(my_macro)] //~ ERROR cannot find derive macro `my_macro` in this scope |
dfeec247 | 49 | //~| ERROR cannot find derive macro `my_macro` in this scope |
416331ca XL |
50 | #[derive(crate::my_macro)] //~ ERROR can't use a procedural macro from the same crate that defines |
51 | //~| ERROR expected derive macro, found macro `crate::my_macro` | |
8faf50e0 XL |
52 | struct CheckDerive1; |
53 | #[derive(my_macro_attr)] //~ ERROR can't use a procedural macro from the same crate that defines it | |
416331ca | 54 | //~| ERROR expected derive macro, found attribute macro `my_macro_attr` |
8faf50e0 XL |
55 | struct CheckDerive2; |
56 | #[derive(MyTrait)] //~ ERROR can't use a procedural macro from the same crate that defines it | |
57 | struct CheckDerive3; |