]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc/inline_cross/auxiliary/proc_macro.rs
Rollup merge of #106407 - mejrs:attr_check, r=compiler-errors
[rust.git] / tests / rustdoc / inline_cross / auxiliary / proc_macro.rs
1 // force-host
2 // no-prefer-dynamic
3 // compile-flags: --crate-type proc-macro
4
5 #![crate_type="proc-macro"]
6 #![crate_name="some_macros"]
7
8 extern crate proc_macro;
9
10 use proc_macro::TokenStream;
11
12 macro_rules! make_attr_macro {
13     ($name:ident) => {
14         /// Generated doc comment
15         #[proc_macro_attribute]
16         pub fn $name(args: TokenStream, input: TokenStream) -> TokenStream {
17             panic!()
18         }
19     }
20 }
21
22 make_attr_macro!(first_attr);
23 make_attr_macro!(second_attr);
24
25 /// a proc-macro that swallows its input and does nothing.
26 #[proc_macro]
27 pub fn some_proc_macro(_input: TokenStream) -> TokenStream {
28     TokenStream::new()
29 }
30
31 /// a proc-macro attribute that passes its item through verbatim.
32 #[proc_macro_attribute]
33 pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream {
34     item
35 }
36
37 /// a derive attribute that adds nothing to its input.
38 #[proc_macro_derive(SomeDerive)]
39 pub fn some_derive(_item: TokenStream) -> TokenStream {
40     TokenStream::new()
41 }
42
43 /// Doc comment from the original crate
44 #[proc_macro]
45 pub fn reexported_macro(_input: TokenStream) -> TokenStream {
46     TokenStream::new()
47 }