Add test, fix pub macro impl, compile error

This commit is contained in:
Rune Tynan 2020-11-26 21:57:11 -05:00
parent 18276b2dbd
commit c007f4354d
No known key found for this signature in database
GPG Key ID: 7ECC932F8B2C731E
2 changed files with 19 additions and 2 deletions

View File

@ -2333,7 +2333,8 @@ impl Clean<Item> for (&hir::MacroDef<'_>, Option<Ident>) {
// This code currently assumes that there will only be one or zero matchers, as syntax
// for multiple is not currently defined.
format!(
"pub macro {}({}) {{\n\t...\n}}",
"{}macro {}{} {{\n\t...\n}}",
item.vis.clean(cx).print_with_space(),
name,
matchers.iter().map(|span| span.to_src(cx)).collect::<String>(),
)
@ -2341,7 +2342,7 @@ impl Clean<Item> for (&hir::MacroDef<'_>, Option<Ident>) {
Item::from_hir_id_and_parts(
item.hir_id,
Some(name.clean(cx)),
Some(name),
MacroItem(Macro { source, imported_from: None }),
cx,
)

View File

@ -0,0 +1,16 @@
#![feature(decl_macro)]
// @has macros_2/macro.my_macro.html //pre 'pub macro my_macro() {'
// @has - //pre '...'
// @has - //pre '}'
pub macro my_macro() {
}
// @has macros_2/macro.my_macro_2.html //pre 'pub macro my_macro_2($($tok:tt)*) {'
// @has - //pre '...'
// @has - //pre '}'
pub macro my_macro_2($($tok:tt)*) {
}