3 // compile-flags: --crate-type proc-macro --document-private-items
5 #![crate_type="proc-macro"]
6 #![crate_name="some_macros"]
8 // @has some_macros/index.html
9 // @has - '//a/[@href="attr.some_proc_attr.html"]' 'some_proc_attr'
11 //! include a link to [some_proc_macro!] to make sure it works.
13 extern crate proc_macro;
15 use proc_macro::TokenStream;
17 // @has some_macros/index.html
18 // @has - '//h2' 'Macros'
19 // @has - '//h2' 'Attribute Macros'
20 // @has - '//h2' 'Derive Macros'
21 // @!has - '//h2' 'Functions'
23 // @has some_macros/all.html
24 // @has - '//a[@href="macro.some_proc_macro.html"]' 'some_proc_macro'
25 // @has - '//a[@href="attr.some_proc_attr.html"]' 'some_proc_attr'
26 // @has - '//a[@href="derive.SomeDerive.html"]' 'SomeDerive'
27 // @!has - '//a/@href' 'fn.some_proc_macro.html'
28 // @!has - '//a/@href' 'fn.some_proc_attr.html'
29 // @!has - '//a/@href' 'fn.some_derive.html'
31 // @has some_macros/index.html '//a/@href' 'macro.some_proc_macro.html'
32 // @!has - '//a/@href' 'fn.some_proc_macro.html'
33 // @has some_macros/macro.some_proc_macro.html
34 // @!has some_macros/fn.some_proc_macro.html
35 /// a proc-macro that swallows its input and does nothing.
37 pub fn some_proc_macro(_input: TokenStream) -> TokenStream {
41 // @has some_macros/index.html '//a/@href' 'attr.some_proc_attr.html'
42 // @!has - '//a/@href' 'fn.some_proc_attr.html'
43 // @has some_macros/attr.some_proc_attr.html
44 // @!has some_macros/fn.some_proc_attr.html
45 /// a proc-macro attribute that passes its item through verbatim.
46 #[proc_macro_attribute]
47 pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream {
51 // @has some_macros/index.html '//a/@href' 'derive.SomeDerive.html'
52 // @!has - '//a/@href' 'fn.some_derive.html'
53 // @has some_macros/derive.SomeDerive.html
54 // @!has some_macros/fn.some_derive.html
55 /// a derive attribute that adds nothing to its input.
56 #[proc_macro_derive(SomeDerive)]
57 pub fn some_derive(_item: TokenStream) -> TokenStream {
61 // @has some_macros/foo/index.html
63 // @has - '//code' 'pub use some_proc_macro;'
64 // @has - '//a/@href' '../macro.some_proc_macro.html'
65 pub use some_proc_macro;
66 // @has - '//code' 'pub use some_proc_attr;'
67 // @has - '//a/@href' '../attr.some_proc_attr.html'
68 pub use some_proc_attr;
69 // @has - '//code' 'pub use some_derive;'
70 // @has - '//a/@href' '../derive.SomeDerive.html'