2018-11-24 13:34:13 +00:00
|
|
|
//@ force-host
|
|
|
|
//@ no-prefer-dynamic
|
|
|
|
|
2016-10-03 16:49:39 +00:00
|
|
|
#![crate_type = "proc-macro"]
|
|
|
|
|
|
|
|
extern crate proc_macro;
|
2019-02-28 05:51:35 +00:00
|
|
|
use proc_macro::*;
|
2016-10-03 16:49:39 +00:00
|
|
|
|
2019-05-22 00:47:23 +00:00
|
|
|
#[proc_macro_derive] //~ ERROR malformed `proc_macro_derive` attribute
|
2019-02-28 05:51:35 +00:00
|
|
|
pub fn foo1(input: TokenStream) -> TokenStream { input }
|
2016-10-03 16:49:39 +00:00
|
|
|
|
2019-05-22 00:47:23 +00:00
|
|
|
#[proc_macro_derive = ""] //~ ERROR malformed `proc_macro_derive` attribute
|
2019-02-28 05:51:35 +00:00
|
|
|
pub fn foo2(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
|
|
|
#[proc_macro_derive(d3, a, b)]
|
2019-05-22 00:47:23 +00:00
|
|
|
//~^ ERROR attribute must have either one or two arguments
|
2019-02-28 05:51:35 +00:00
|
|
|
pub fn foo3(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
|
|
|
#[proc_macro_derive(d4, attributes(a), b)]
|
2019-05-22 00:47:23 +00:00
|
|
|
//~^ ERROR attribute must have either one or two arguments
|
2019-02-28 05:51:35 +00:00
|
|
|
pub fn foo4(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
|
|
|
#[proc_macro_derive("a")]
|
|
|
|
//~^ ERROR: not a meta item
|
|
|
|
pub fn foo5(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
|
|
|
#[proc_macro_derive(d6 = "")]
|
|
|
|
//~^ ERROR: must only be one word
|
|
|
|
pub fn foo6(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
|
|
|
#[proc_macro_derive(m::d7)]
|
2019-02-28 06:17:24 +00:00
|
|
|
//~^ ERROR: must only be one word
|
2019-02-28 05:51:35 +00:00
|
|
|
pub fn foo7(input: TokenStream) -> TokenStream { input }
|
2016-10-03 16:49:39 +00:00
|
|
|
|
2019-02-28 05:51:35 +00:00
|
|
|
#[proc_macro_derive(d8(a))]
|
2016-10-03 16:49:39 +00:00
|
|
|
//~^ ERROR: must only be one word
|
2019-02-28 05:51:35 +00:00
|
|
|
pub fn foo8(input: TokenStream) -> TokenStream { input }
|
2016-11-08 11:15:02 +00:00
|
|
|
|
2019-02-28 05:51:35 +00:00
|
|
|
#[proc_macro_derive(self)]
|
2019-03-03 16:04:58 +00:00
|
|
|
//~^ ERROR: `self` cannot be a name of derive macro
|
2019-02-28 05:51:35 +00:00
|
|
|
pub fn foo9(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
2019-06-20 08:52:31 +00:00
|
|
|
#[proc_macro_derive(PartialEq)] // OK
|
2019-02-28 05:51:35 +00:00
|
|
|
pub fn foo10(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
|
|
|
#[proc_macro_derive(d11, a)]
|
|
|
|
//~^ ERROR: second argument must be `attributes`
|
|
|
|
//~| ERROR: attribute must be of form: `attributes(foo, bar)`
|
|
|
|
pub fn foo11(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
|
|
|
#[proc_macro_derive(d12, attributes)]
|
|
|
|
//~^ ERROR: attribute must be of form: `attributes(foo, bar)`
|
|
|
|
pub fn foo12(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
|
|
|
#[proc_macro_derive(d13, attributes("a"))]
|
2022-11-15 13:24:33 +00:00
|
|
|
//~^ ERROR: attribute must be a meta item, not a literal
|
2019-02-28 05:51:35 +00:00
|
|
|
pub fn foo13(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
|
|
|
#[proc_macro_derive(d14, attributes(a = ""))]
|
2022-11-15 13:24:33 +00:00
|
|
|
//~^ ERROR: attribute must only be a single word
|
2019-02-28 05:51:35 +00:00
|
|
|
pub fn foo14(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
|
|
|
#[proc_macro_derive(d15, attributes(m::a))]
|
2022-11-15 13:24:33 +00:00
|
|
|
//~^ ERROR: attribute must only be a single word
|
2019-02-28 05:51:35 +00:00
|
|
|
pub fn foo15(input: TokenStream) -> TokenStream { input }
|
2016-11-08 11:15:02 +00:00
|
|
|
|
2019-02-28 05:51:35 +00:00
|
|
|
#[proc_macro_derive(d16, attributes(a(b)))]
|
2022-11-15 13:24:33 +00:00
|
|
|
//~^ ERROR: attribute must only be a single word
|
2019-02-28 05:51:35 +00:00
|
|
|
pub fn foo16(input: TokenStream) -> TokenStream { input }
|
2016-11-08 11:15:02 +00:00
|
|
|
|
2019-02-28 05:51:35 +00:00
|
|
|
#[proc_macro_derive(d17, attributes(self))]
|
2019-03-03 16:04:58 +00:00
|
|
|
//~^ ERROR: `self` cannot be a name of derive helper attribute
|
2019-02-28 05:51:35 +00:00
|
|
|
pub fn foo17(input: TokenStream) -> TokenStream { input }
|