]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/proc-macro.rs
Auto merge of #57119 - jethrogb:jb/sgx-os-mod2, r=joshtriplett
[rust.git] / src / test / rustdoc / proc-macro.rs
1 // force-host
2 // no-prefer-dynamic
3
4 #![crate_type="proc-macro"]
5 #![crate_name="some_macros"]
6
7 extern crate proc_macro;
8
9 use proc_macro::TokenStream;
10
11 // @has some_macros/index.html
12 // @has - '//h2' 'Macros'
13 // @has - '//h2' 'Attribute Macros'
14 // @has - '//h2' 'Derive Macros'
15 // @!has - '//h2' 'Functions'
16
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'
24
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.
30 #[proc_macro]
31 pub fn some_proc_macro(_input: TokenStream) -> TokenStream {
32     TokenStream::new()
33 }
34
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 {
42     item
43 }
44
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 {
52     TokenStream::new()
53 }
54
55 // @has some_macros/foo/index.html
56 pub mod foo {
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'
65     pub use some_derive;
66 }