4 #![crate_type="proc-macro"]
5 #![crate_name="some_macros"]
7 extern crate proc_macro;
9 use proc_macro::TokenStream;
11 // @has some_macros/index.html
12 // @has - '//h2' 'Macros'
13 // @has - '//h2' 'Attribute Macros'
14 // @has - '//h2' 'Derive Macros'
15 // @!has - '//h2' 'Functions'
17 // @has some_macros/all.html
18 // @has - '//a[@href="macro.some_proc_macro.html"]' 'some_proc_macro'
19 // @has - '//a[@href="attr.some_proc_attr.html"]' 'some_proc_attr'
20 // @has - '//a[@href="derive.SomeDerive.html"]' 'SomeDerive'
21 // @!has - '//a/@href' 'fn.some_proc_macro.html'
22 // @!has - '//a/@href' 'fn.some_proc_attr.html'
23 // @!has - '//a/@href' 'fn.some_derive.html'
25 // @has some_macros/index.html '//a/@href' 'macro.some_proc_macro.html'
26 // @!has - '//a/@href' 'fn.some_proc_macro.html'
27 // @has some_macros/macro.some_proc_macro.html
28 // @!has some_macros/fn.some_proc_macro.html
29 /// a proc-macro that swallows its input and does nothing.
31 pub fn some_proc_macro(_input: TokenStream) -> TokenStream {
35 // @has some_macros/index.html '//a/@href' 'attr.some_proc_attr.html'
36 // @!has - '//a/@href' 'fn.some_proc_attr.html'
37 // @has some_macros/attr.some_proc_attr.html
38 // @!has some_macros/fn.some_proc_attr.html
39 /// a proc-macro attribute that passes its item through verbatim.
40 #[proc_macro_attribute]
41 pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream {
45 // @has some_macros/index.html '//a/@href' 'derive.SomeDerive.html'
46 // @!has - '//a/@href' 'fn.some_derive.html'
47 // @has some_macros/derive.SomeDerive.html
48 // @!has some_macros/fn.some_derive.html
49 /// a derive attribute that adds nothing to its input.
50 #[proc_macro_derive(SomeDerive)]
51 pub fn some_derive(_item: TokenStream) -> TokenStream {
55 // @has some_macros/foo/index.html
57 // @has - '//code' 'pub use some_proc_macro;'
58 // @has - '//a/@href' '../../some_macros/macro.some_proc_macro.html'
59 pub use some_proc_macro;
60 // @has - '//code' 'pub use some_proc_attr;'
61 // @has - '//a/@href' '../../some_macros/attr.some_proc_attr.html'
62 pub use some_proc_attr;
63 // @has - '//code' 'pub use some_derive;'
64 // @has - '//a/@href' '../../some_macros/derive.SomeDerive.html'