4 #![crate_type="proc-macro"]
5 #![crate_name="some_macros"]
7 // @has some_macros/index.html
8 // @has - '//a/[@href="attr.some_proc_attr.html"]' 'some_proc_attr'
10 //! include a link to [some_proc_attr] to make sure it works.
12 extern crate proc_macro;
14 use proc_macro::TokenStream;
16 // @has some_macros/index.html
17 // @has - '//h2' 'Macros'
18 // @has - '//h2' 'Attribute Macros'
19 // @has - '//h2' 'Derive Macros'
20 // @!has - '//h2' 'Functions'
22 // @has some_macros/all.html
23 // @has - '//a[@href="macro.some_proc_macro.html"]' 'some_proc_macro'
24 // @has - '//a[@href="attr.some_proc_attr.html"]' 'some_proc_attr'
25 // @has - '//a[@href="derive.SomeDerive.html"]' 'SomeDerive'
26 // @!has - '//a/@href' 'fn.some_proc_macro.html'
27 // @!has - '//a/@href' 'fn.some_proc_attr.html'
28 // @!has - '//a/@href' 'fn.some_derive.html'
30 // @has some_macros/index.html '//a/@href' 'macro.some_proc_macro.html'
31 // @!has - '//a/@href' 'fn.some_proc_macro.html'
32 // @has some_macros/macro.some_proc_macro.html
33 // @!has some_macros/fn.some_proc_macro.html
34 /// a proc-macro that swallows its input and does nothing.
36 pub fn some_proc_macro(_input: TokenStream) -> TokenStream {
40 // @has some_macros/index.html '//a/@href' 'attr.some_proc_attr.html'
41 // @!has - '//a/@href' 'fn.some_proc_attr.html'
42 // @has some_macros/attr.some_proc_attr.html
43 // @!has some_macros/fn.some_proc_attr.html
44 /// a proc-macro attribute that passes its item through verbatim.
45 #[proc_macro_attribute]
46 pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream {
50 // @has some_macros/index.html '//a/@href' 'derive.SomeDerive.html'
51 // @!has - '//a/@href' 'fn.some_derive.html'
52 // @has some_macros/derive.SomeDerive.html
53 // @!has some_macros/fn.some_derive.html
54 /// a derive attribute that adds nothing to its input.
55 #[proc_macro_derive(SomeDerive)]
56 pub fn some_derive(_item: TokenStream) -> TokenStream {
60 // @has some_macros/foo/index.html
62 // @has - '//code' 'pub use some_proc_macro;'
63 // @has - '//a/@href' '../../some_macros/macro.some_proc_macro.html'
64 pub use some_proc_macro;
65 // @has - '//code' 'pub use some_proc_attr;'
66 // @has - '//a/@href' '../../some_macros/attr.some_proc_attr.html'
67 pub use some_proc_attr;
68 // @has - '//code' 'pub use some_derive;'
69 // @has - '//a/@href' '../../some_macros/derive.SomeDerive.html'