]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/proc-macro.rs
bfd194701c85db8714742757102117ea51984446
[rust.git] / src / test / rustdoc / proc-macro.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-stage1
12
13 #![crate_type="proc-macro"]
14 #![crate_name="some_macros"]
15
16 extern crate proc_macro;
17
18 use proc_macro::TokenStream;
19
20 // @has some_macros/index.html
21 // @has - '//h2' 'Macros'
22 // @has - '//h2' 'Attribute Macros'
23 // @has - '//h2' 'Derive Macros'
24 // @!has - '//h2' 'Functions'
25
26 // @has some_macros/all.html
27 // @has - '//a[@href="macro.some_proc_macro.html"]' 'some_proc_macro'
28 // @has - '//a[@href="attr.some_proc_attr.html"]' 'some_proc_attr'
29 // @has - '//a[@href="derive.SomeDerive.html"]' 'SomeDerive'
30 // @!has - '//a/@href' 'fn.some_proc_macro.html'
31 // @!has - '//a/@href' 'fn.some_proc_attr.html'
32 // @!has - '//a/@href' 'fn.some_derive.html'
33
34 // @has some_macros/index.html '//a/@href' 'macro.some_proc_macro.html'
35 // @!has - '//a/@href' 'fn.some_proc_macro.html'
36 // @has some_macros/macro.some_proc_macro.html
37 // @!has some_macros/fn.some_proc_macro.html
38 /// a proc-macro that swallows its input and does nothing.
39 #[proc_macro]
40 pub fn some_proc_macro(_input: TokenStream) -> TokenStream {
41     TokenStream::new()
42 }
43
44 // @has some_macros/index.html '//a/@href' 'attr.some_proc_attr.html'
45 // @!has - '//a/@href' 'fn.some_proc_attr.html'
46 // @has some_macros/attr.some_proc_attr.html
47 // @!has some_macros/fn.some_proc_attr.html
48 /// a proc-macro attribute that passes its item through verbatim.
49 #[proc_macro_attribute]
50 pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream {
51     item
52 }
53
54 // @has some_macros/index.html '//a/@href' 'derive.SomeDerive.html'
55 // @!has - '//a/@href' 'fn.some_derive.html'
56 // @has some_macros/derive.SomeDerive.html
57 // @!has some_macros/fn.some_derive.html
58 /// a derive attribute that adds nothing to its input.
59 #[proc_macro_derive(SomeDerive)]
60 pub fn some_derive(_item: TokenStream) -> TokenStream {
61     TokenStream::new()
62 }