2018-11-24 07:34:13 -06:00
|
|
|
// force-host
|
|
|
|
// no-prefer-dynamic
|
|
|
|
|
2016-10-03 11:49:39 -05:00
|
|
|
#![crate_type = "proc-macro"]
|
|
|
|
|
|
|
|
extern crate proc_macro;
|
2019-02-27 23:51:35 -06:00
|
|
|
use proc_macro::*;
|
2016-10-03 11:49:39 -05:00
|
|
|
|
2019-05-21 19:47:23 -05:00
|
|
|
#[proc_macro_derive] //~ ERROR malformed `proc_macro_derive` attribute
|
2019-02-27 23:51:35 -06:00
|
|
|
pub fn foo1(input: TokenStream) -> TokenStream { input }
|
2016-10-03 11:49:39 -05:00
|
|
|
|
2019-05-21 19:47:23 -05:00
|
|
|
#[proc_macro_derive = ""] //~ ERROR malformed `proc_macro_derive` attribute
|
2019-02-27 23:51:35 -06:00
|
|
|
pub fn foo2(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
|
|
|
#[proc_macro_derive(d3, a, b)]
|
2019-05-21 19:47:23 -05:00
|
|
|
//~^ ERROR attribute must have either one or two arguments
|
2019-02-27 23:51:35 -06:00
|
|
|
pub fn foo3(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
|
|
|
#[proc_macro_derive(d4, attributes(a), b)]
|
2019-05-21 19:47:23 -05:00
|
|
|
//~^ ERROR attribute must have either one or two arguments
|
2019-02-27 23:51:35 -06: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 00:17:24 -06:00
|
|
|
//~^ ERROR: must only be one word
|
2019-02-27 23:51:35 -06:00
|
|
|
pub fn foo7(input: TokenStream) -> TokenStream { input }
|
2016-10-03 11:49:39 -05:00
|
|
|
|
2019-02-27 23:51:35 -06:00
|
|
|
#[proc_macro_derive(d8(a))]
|
2016-10-03 11:49:39 -05:00
|
|
|
//~^ ERROR: must only be one word
|
2019-02-27 23:51:35 -06:00
|
|
|
pub fn foo8(input: TokenStream) -> TokenStream { input }
|
2016-11-08 05:15:02 -06:00
|
|
|
|
2019-02-27 23:51:35 -06:00
|
|
|
#[proc_macro_derive(self)]
|
2019-03-03 10:04:58 -06:00
|
|
|
//~^ ERROR: `self` cannot be a name of derive macro
|
2019-02-27 23:51:35 -06:00
|
|
|
pub fn foo9(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
2019-06-20 03:52:31 -05:00
|
|
|
#[proc_macro_derive(PartialEq)] // OK
|
2019-02-27 23:51:35 -06: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 07:24:33 -06:00
|
|
|
//~^ ERROR: attribute must be a meta item, not a literal
|
2019-02-27 23:51:35 -06:00
|
|
|
pub fn foo13(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
|
|
|
#[proc_macro_derive(d14, attributes(a = ""))]
|
2022-11-15 07:24:33 -06:00
|
|
|
//~^ ERROR: attribute must only be a single word
|
2019-02-27 23:51:35 -06:00
|
|
|
pub fn foo14(input: TokenStream) -> TokenStream { input }
|
|
|
|
|
|
|
|
#[proc_macro_derive(d15, attributes(m::a))]
|
2022-11-15 07:24:33 -06:00
|
|
|
//~^ ERROR: attribute must only be a single word
|
2019-02-27 23:51:35 -06:00
|
|
|
pub fn foo15(input: TokenStream) -> TokenStream { input }
|
2016-11-08 05:15:02 -06:00
|
|
|
|
2019-02-27 23:51:35 -06:00
|
|
|
#[proc_macro_derive(d16, attributes(a(b)))]
|
2022-11-15 07:24:33 -06:00
|
|
|
//~^ ERROR: attribute must only be a single word
|
2019-02-27 23:51:35 -06:00
|
|
|
pub fn foo16(input: TokenStream) -> TokenStream { input }
|
2016-11-08 05:15:02 -06:00
|
|
|
|
2019-02-27 23:51:35 -06:00
|
|
|
#[proc_macro_derive(d17, attributes(self))]
|
2019-03-03 10:04:58 -06:00
|
|
|
//~^ ERROR: `self` cannot be a name of derive helper attribute
|
2019-02-27 23:51:35 -06:00
|
|
|
pub fn foo17(input: TokenStream) -> TokenStream { input }
|