]> git.lizzy.rs Git - rust.git/blob - tests/ui/proc-macro/macro-namespace-reserved-2.rs
Auto merge of #106959 - tmiasko:opt-funclets, r=davidtwco
[rust.git] / tests / ui / proc-macro / macro-namespace-reserved-2.rs
1 // force-host
2 // no-prefer-dynamic
3
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() {
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`
31 }
32 fn check_bang3() {
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`
36 }
37
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`
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
45            //~| ERROR expected attribute, found derive macro `MyTrait`
46 fn check_attr3() {}
47
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`
52 struct CheckDerive1;
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`
55 struct CheckDerive2;
56 #[derive(MyTrait)] //~ ERROR can't use a procedural macro from the same crate that defines it
57 struct CheckDerive3;