diff options
| author | Michael Goulet <michael@errs.io> | 2024-02-19 16:07:39 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-02-21 05:32:08 +0000 |
| commit | 62e7414a194fb64715933d720e0505553c0834f7 (patch) | |
| tree | 71779e862cf6a0416fa3fa244aac88bc651853fa /compiler/rustc_macros/src/lib.rs | |
| parent | 29f87ade9d78d233e85ef6ca2d6153d0d4fd38d6 (diff) | |
| download | rust-62e7414a194fb64715933d720e0505553c0834f7.tar.gz rust-62e7414a194fb64715933d720e0505553c0834f7.zip | |
Docs for extension proc-macro
Diffstat (limited to 'compiler/rustc_macros/src/lib.rs')
| -rw-r--r-- | compiler/rustc_macros/src/lib.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs index 619f93c8a53..14e6a06839e 100644 --- a/compiler/rustc_macros/src/lib.rs +++ b/compiler/rustc_macros/src/lib.rs @@ -41,6 +41,20 @@ pub fn symbols(input: TokenStream) -> TokenStream { 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] pub fn extension(attr: TokenStream, input: TokenStream) -> TokenStream { extension::extension(attr, input) |
