1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // At time of authorship, #[proc_macro_derive = "2500"] will emit an
12 // error when it occurs on a mod (apart from crate-level), but will
13 // not descend further into the mod for other occurrences of the same
16 // This file sits on its own because the the "weird" occurrences here
17 // signal errors, making it incompatible with the "warnings only"
18 // nature of issue-43106-gating-of-builtin-attrs.rs
20 #[proc_macro_derive = "2500"]
21 //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
22 mod proc_macro_derive1 {
23 mod inner { #![proc_macro_derive="2500"] }
24 // (no error issued here if there was one on outer module)
27 mod proc_macro_derive2 {
28 mod inner { #![proc_macro_derive="2500"] }
29 //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
31 #[proc_macro_derive = "2500"] fn f() { }
32 //~^ ERROR the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro`
34 #[proc_macro_derive = "2500"] struct S;
35 //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
37 #[proc_macro_derive = "2500"] type T = S;
38 //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
40 #[proc_macro_derive = "2500"] impl S { }
41 //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions