]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc/proc-macro.rs
Remove astconv usage in diagnostic
[rust.git] / tests / rustdoc / proc-macro.rs
1 // force-host
2 // no-prefer-dynamic
3 // compile-flags: --crate-type proc-macro --document-private-items
4
5 #![crate_type="proc-macro"]
6 #![crate_name="some_macros"]
7
8 // @has some_macros/index.html
9 // @has - '//a/[@href="attr.some_proc_attr.html"]' 'some_proc_attr'
10
11 //! include a link to [some_proc_macro!] to make sure it works.
12
13 extern crate proc_macro;
14
15 use proc_macro::TokenStream;
16
17 // @has some_macros/index.html
18 // @has - '//h2' 'Macros'
19 // @has - '//h2' 'Attribute Macros'
20 // @has - '//h2' 'Derive Macros'
21 // @!has - '//h2' 'Functions'
22
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'
30
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.
36 #[proc_macro]
37 pub fn some_proc_macro(_input: TokenStream) -> TokenStream {
38     TokenStream::new()
39 }
40
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 {
48     item
49 }
50
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 {
58     TokenStream::new()
59 }
60
61 // @has some_macros/foo/index.html
62 mod foo {
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'
71     pub use some_derive;
72 }