Closed
Description
When creating a macro tagged with #[macro_export]
inside of a proc_macro_derive
the documentation incorrectly displays the name of the derive instead of the match pattern.
I tried this code: (everything is the same as here except for "main.rs" and "impl_hello_world()").
main.rs:
#[macro_use]
extern crate hello_world_derive;
#[derive(HelloWorld)]
struct Foo {
}
fn main() {
Foo!("Hi");
}
hello-world-derive/src/lib.rs:
/* ... */
fn impl_hello_world(ast: &syn::DeriveInput) -> quote::Tokens {
let name = &ast.ident;
quote! {
#[macro_export]
macro_rules! #name {
($expr:expr) => {
println!("expr: {}", $expr);
}
}
}
}
When opening the automatic documentation(cargo doc --open
) I expected Foo!
to look like this:
macro_rules! Foo {
($expr:expr) => { ... };
}
Instead, Foo looked like this: ( the name of the derive instead of the actual match pattern.)
macro_rules! Foo {
HelloWorld => { ... };
}
In case the created macro has more than 1 match arm it looks like this:
macro_rules! Foo {
HelloWorld => { ... };
HelloWorld => { ... };
}
Meta
rustc --version --verbose
:
rustc 1.19.0 (0ade339 2017-07-17)
binary: rustc
commit-hash: 0ade339
commit-date: 2017-07-17
host: x86_64-pc-windows-msvc
release: 1.19.0
LLVM version: 4.0