mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-21 20:17:55 +00:00
Rollup merge of #121304 - compiler-errors:ext, r=nnethercote
Add docs for extension proc-macro r? nnethercote
This commit is contained in:
commit
94e459f1a9
@ -41,6 +41,20 @@ pub fn symbols(input: TokenStream) -> TokenStream {
|
|||||||
symbols::symbols(input.into()).into()
|
symbols::symbols(input.into()).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Derive an extension trait for a given impl block. The trait name
|
||||||
|
/// goes into the parenthesized args of the macro, for greppability.
|
||||||
|
/// For example:
|
||||||
|
/// ```
|
||||||
|
/// use rustc_macros::extension;
|
||||||
|
/// #[extension(pub trait Foo)]
|
||||||
|
/// impl i32 { fn hello() {} }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// expands to:
|
||||||
|
/// ```
|
||||||
|
/// pub trait Foo { fn hello(); }
|
||||||
|
/// impl Foo for i32 { fn hello() {} }
|
||||||
|
/// ```
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn extension(attr: TokenStream, input: TokenStream) -> TokenStream {
|
pub fn extension(attr: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
extension::extension(attr, input)
|
extension::extension(attr, input)
|
||||||
|
Loading…
Reference in New Issue
Block a user