4 #![crate_type = "proc-macro"]
6 extern crate proc_macro;
10 pub fn my_macro(input: TokenStream) -> TokenStream {
14 #[proc_macro_attribute]
15 pub fn my_macro_attr(input: TokenStream, _: TokenStream) -> TokenStream {
19 #[proc_macro_derive(MyTrait)]
20 pub fn my_macro_derive(input: TokenStream) -> TokenStream {
25 my_macro!(); //~ ERROR can't use a procedural macro from the same crate that defines it
28 my_macro_attr!(); //~ ERROR cannot find macro `my_macro_attr` in this scope
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`
33 MyTrait!(); //~ ERROR cannot find macro `MyTrait` in this scope
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`
38 #[my_macro] //~ ERROR cannot find attribute `my_macro` in this scope
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`
42 #[my_macro_attr] //~ ERROR can't use a procedural macro from the same crate that defines it
44 #[MyTrait] //~ ERROR can't use a procedural macro from the same crate that defines it
45 //~| ERROR expected attribute, found derive macro `MyTrait`
48 #[derive(my_macro)] //~ ERROR cannot find derive macro `my_macro` in this scope
49 //~| ERROR cannot find derive macro `my_macro` in this scope
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`
53 #[derive(my_macro_attr)] //~ ERROR can't use a procedural macro from the same crate that defines it
54 //~| ERROR expected derive macro, found attribute macro `my_macro_attr`
56 #[derive(MyTrait)] //~ ERROR can't use a procedural macro from the same crate that defines it