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