]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/proc-macro.rs
Rollup merge of #61146 - czipperz:SliceConcatExt-connect-default-to-join, r=sfackler
[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 // @has some_macros/index.html
8 // @has - '//a/[@href="attr.some_proc_attr.html"]' 'some_proc_attr'
9
10 //! include a link to [some_proc_attr] to make sure it works.
11
12 extern crate proc_macro;
13
14 use proc_macro::TokenStream;
15
16 // @has some_macros/index.html
17 // @has - '//h2' 'Macros'
18 // @has - '//h2' 'Attribute Macros'
19 // @has - '//h2' 'Derive Macros'
20 // @!has - '//h2' 'Functions'
21
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'
29
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.
35 #[proc_macro]
36 pub fn some_proc_macro(_input: TokenStream) -> TokenStream {
37     TokenStream::new()
38 }
39
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 {
47     item
48 }
49
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 {
57     TokenStream::new()
58 }
59
60 // @has some_macros/foo/index.html
61 pub mod foo {
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'
70     pub use some_derive;
71 }