issue-43106-gating-of-proc_macro_derive.rs 1.3 KB
Newer Older
1 2 3 4 5
// At time of authorship, #[proc_macro_derive = "2500"] will emit an
// error when it occurs on a mod (apart from crate-level), but will
// not descend further into the mod for other occurrences of the same
// error.
//
B
Bruce Mitchener 已提交
6
// This file sits on its own because the "weird" occurrences here
7 8 9
// signal errors, making it incompatible with the "warnings only"
// nature of issue-43106-gating-of-builtin-attrs.rs

10
#[proc_macro_derive()]
11 12
//~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
mod proc_macro_derive1 {
13
    mod inner { #![proc_macro_derive()] }
14 15 16 17
    // (no error issued here if there was one on outer module)
}

mod proc_macro_derive2 {
18
    mod inner { #![proc_macro_derive()] }
19 20
    //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions

21
    #[proc_macro_derive()] fn f() { }
22 23
    //~^ ERROR the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro`

24
    #[proc_macro_derive()] struct S;
25 26
    //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions

27
    #[proc_macro_derive()] type T = S;
28 29
    //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions

30
    #[proc_macro_derive()] impl S { }
31 32
    //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
}
33 34

fn main() {}