Skip to content

Commit

Permalink
Merge pull request rust-lang#3440 from rchaser53/issue-3439
Browse files Browse the repository at this point in the history
fix 'Ident of macro+ident gets duplicated' error
  • Loading branch information
topecongiro authored Mar 10, 2019
2 parents 06fc39f + 40ff078 commit 4f3a353
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
6 changes: 6 additions & 0 deletions tests/target/issue-3439.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use repro::my_macro;

#[my_macro]
xyz! abc {
let a = 1;
}

0 comments on commit 4f3a353

Please sign in to comment.