2018-11-24 07:34:13 -06:00
|
|
|
//@ force-host
|
|
|
|
//@ no-prefer-dynamic
|
2019-07-20 15:34:41 -05:00
|
|
|
//@ compile-flags: --crate-type proc-macro --document-private-items
|
2018-11-24 07:34:13 -06:00
|
|
|
|
2018-09-25 14:56:43 -05:00
|
|
|
#![crate_type="proc-macro"]
|
|
|
|
#![crate_name="some_macros"]
|
|
|
|
|
2019-01-22 15:44:19 -06:00
|
|
|
// @has some_macros/index.html
|
|
|
|
// @has - '//a/[@href="attr.some_proc_attr.html"]' 'some_proc_attr'
|
|
|
|
|
2021-11-26 17:03:16 -06:00
|
|
|
//! include a link to [some_proc_macro!] to make sure it works.
|
2019-01-22 15:44:19 -06:00
|
|
|
|
2018-09-25 14:56:43 -05:00
|
|
|
extern crate proc_macro;
|
|
|
|
|
|
|
|
use proc_macro::TokenStream;
|
|
|
|
|
|
|
|
// @has some_macros/index.html
|
|
|
|
// @has - '//h2' 'Macros'
|
|
|
|
// @has - '//h2' 'Attribute Macros'
|
|
|
|
// @has - '//h2' 'Derive Macros'
|
|
|
|
// @!has - '//h2' 'Functions'
|
|
|
|
|
2018-09-27 10:22:29 -05:00
|
|
|
// @has some_macros/all.html
|
|
|
|
// @has - '//a[@href="macro.some_proc_macro.html"]' 'some_proc_macro'
|
|
|
|
// @has - '//a[@href="attr.some_proc_attr.html"]' 'some_proc_attr'
|
|
|
|
// @has - '//a[@href="derive.SomeDerive.html"]' 'SomeDerive'
|
|
|
|
// @!has - '//a/@href' 'fn.some_proc_macro.html'
|
|
|
|
// @!has - '//a/@href' 'fn.some_proc_attr.html'
|
|
|
|
// @!has - '//a/@href' 'fn.some_derive.html'
|
|
|
|
|
2018-09-25 14:56:43 -05:00
|
|
|
// @has some_macros/index.html '//a/@href' 'macro.some_proc_macro.html'
|
|
|
|
// @!has - '//a/@href' 'fn.some_proc_macro.html'
|
|
|
|
// @has some_macros/macro.some_proc_macro.html
|
|
|
|
// @!has some_macros/fn.some_proc_macro.html
|
|
|
|
/// a proc-macro that swallows its input and does nothing.
|
|
|
|
#[proc_macro]
|
|
|
|
pub fn some_proc_macro(_input: TokenStream) -> TokenStream {
|
|
|
|
TokenStream::new()
|
|
|
|
}
|
|
|
|
|
|
|
|
// @has some_macros/index.html '//a/@href' 'attr.some_proc_attr.html'
|
|
|
|
// @!has - '//a/@href' 'fn.some_proc_attr.html'
|
|
|
|
// @has some_macros/attr.some_proc_attr.html
|
|
|
|
// @!has some_macros/fn.some_proc_attr.html
|
|
|
|
/// a proc-macro attribute that passes its item through verbatim.
|
|
|
|
#[proc_macro_attribute]
|
|
|
|
pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
|
item
|
|
|
|
}
|
|
|
|
|
|
|
|
// @has some_macros/index.html '//a/@href' 'derive.SomeDerive.html'
|
|
|
|
// @!has - '//a/@href' 'fn.some_derive.html'
|
|
|
|
// @has some_macros/derive.SomeDerive.html
|
|
|
|
// @!has some_macros/fn.some_derive.html
|
|
|
|
/// a derive attribute that adds nothing to its input.
|
|
|
|
#[proc_macro_derive(SomeDerive)]
|
|
|
|
pub fn some_derive(_item: TokenStream) -> TokenStream {
|
|
|
|
TokenStream::new()
|
|
|
|
}
|
2018-12-08 12:27:12 -06:00
|
|
|
|
|
|
|
// @has some_macros/foo/index.html
|
2019-07-20 15:34:41 -05:00
|
|
|
mod foo {
|
2018-12-08 12:27:12 -06:00
|
|
|
// @has - '//code' 'pub use some_proc_macro;'
|
2021-03-17 13:41:01 -05:00
|
|
|
// @has - '//a/@href' '../macro.some_proc_macro.html'
|
2018-12-08 12:27:12 -06:00
|
|
|
pub use some_proc_macro;
|
|
|
|
// @has - '//code' 'pub use some_proc_attr;'
|
2021-03-17 13:41:01 -05:00
|
|
|
// @has - '//a/@href' '../attr.some_proc_attr.html'
|
2018-12-08 12:27:12 -06:00
|
|
|
pub use some_proc_attr;
|
|
|
|
// @has - '//code' 'pub use some_derive;'
|
2021-03-17 13:41:01 -05:00
|
|
|
// @has - '//a/@href' '../derive.SomeDerive.html'
|
2018-12-08 12:27:12 -06:00
|
|
|
pub use some_derive;
|
|
|
|
}
|