fix 'Ident of macro+ident gets duplicated' error

This commit is contained in:
rchaser53 2019-03-10 22:58:34 +09:00
parent 06fc39f905
commit 40ff078abf
2 changed files with 8 additions and 1 deletions

View File

@ -432,7 +432,8 @@ pub fn rewrite_macro_inner(
// the `macro_name!` and `{ /* macro_body */ }` but skip modifying
// anything in between the braces (for now).
let snippet = context.snippet(mac.span);
let macro_raw = snippet.split_at(snippet.find('!')? + 1).1.trim_start();
// to remove unnecessary space after macro name
let macro_raw = snippet.trim_start_matches(&macro_name).trim_start();
match trim_left_preserve_layout(macro_raw, shape.indent, &context.config) {
Some(macro_body) => Some(format!("{} {}", macro_name, macro_body)),
None => Some(format!("{} {}", macro_name, macro_raw)),

View File

@ -0,0 +1,6 @@
use repro::my_macro;
#[my_macro]
xyz! abc {
let a = 1;
}