summaryrefslogtreecommitdiffstats
path: root/src/test/ui/proc-macro/attribute.rs
blob: 5531b32362125b4a4ed227dab4a785b9b3cb08d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// force-host
// no-prefer-dynamic

#![crate_type = "proc-macro"]

extern crate proc_macro;
use proc_macro::*;

#[proc_macro_derive] //~ ERROR malformed `proc_macro_derive` attribute
pub fn foo1(input: TokenStream) -> TokenStream { input }

#[proc_macro_derive = ""] //~ ERROR malformed `proc_macro_derive` attribute
pub fn foo2(input: TokenStream) -> TokenStream { input }

#[proc_macro_derive(d3, a, b)]
//~^ ERROR attribute must have either one or two arguments
pub fn foo3(input: TokenStream) -> TokenStream { input }

#[proc_macro_derive(d4, attributes(a), b)]
//~^ ERROR attribute must have either one or two arguments
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)]
//~^ ERROR: must only be one word
pub fn foo7(input: TokenStream) -> TokenStream { input }

#[proc_macro_derive(d8(a))]
//~^ ERROR: must only be one word
pub fn foo8(input: TokenStream) -> TokenStream { input }

#[proc_macro_derive(self)]
//~^ ERROR: `self` cannot be a name of derive macro
pub fn foo9(input: TokenStream) -> TokenStream { input }

#[proc_macro_derive(PartialEq)] // OK
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"))]
//~^ ERROR: not a meta item
pub fn foo13(input: TokenStream) -> TokenStream { input }

#[proc_macro_derive(d14, attributes(a = ""))]
//~^ ERROR: must only be one word
pub fn foo14(input: TokenStream) -> TokenStream { input }

#[proc_macro_derive(d15, attributes(m::a))]
//~^ ERROR: must only be one word
pub fn foo15(input: TokenStream) -> TokenStream { input }

#[proc_macro_derive(d16, attributes(a(b)))]
//~^ ERROR: must only be one word
pub fn foo16(input: TokenStream) -> TokenStream { input }

#[proc_macro_derive(d17, attributes(self))]
//~^ ERROR: `self` cannot be a name of derive helper attribute
pub fn foo17(input: TokenStream) -> TokenStream { input }