]> git.lizzy.rs Git - rust.git/blob - src/test/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs
Rollup merge of #94449 - GuillaumeGomez:explanation-e0726, r=Urgau
[rust.git] / src / test / ui / feature-gates / issue-43106-gating-of-proc_macro_derive.rs
1 // At time of authorship, #[proc_macro_derive = "2500"] will emit an
2 // error when it occurs on a mod (apart from crate-level), but will
3 // not descend further into the mod for other occurrences of the same
4 // error.
5 //
6 // This file sits on its own because the "weird" occurrences here
7 // signal errors, making it incompatible with the "warnings only"
8 // nature of issue-43106-gating-of-builtin-attrs.rs
9
10 #[proc_macro_derive()]
11 //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
12 mod proc_macro_derive1 {
13     mod inner { #![proc_macro_derive()] }
14     // (no error issued here if there was one on outer module)
15 }
16
17 mod proc_macro_derive2 {
18     mod inner { #![proc_macro_derive()] }
19     //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
20
21     #[proc_macro_derive()] fn f() { }
22     //~^ ERROR the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro`
23
24     #[proc_macro_derive()] struct S;
25     //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
26
27     #[proc_macro_derive()] type T = S;
28     //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
29
30     #[proc_macro_derive()] impl S { }
31     //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
32 }
33
34 fn main() {}