Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 4f3a353

Browse files
authored
Merge pull request rust-lang#3440 from rchaser53/issue-3439
fix 'Ident of macro+ident gets duplicated' error
2 parents 06fc39f + 40ff078 commit 4f3a353

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/macros.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ pub fn rewrite_macro_inner(
432432
// the `macro_name!` and `{ /* macro_body */ }` but skip modifying
433433
// anything in between the braces (for now).
434434
let snippet = context.snippet(mac.span);
435-
let macro_raw = snippet.split_at(snippet.find('!')? + 1).1.trim_start();
435+
// to remove unnecessary space after macro name
436+
let macro_raw = snippet.trim_start_matches(&macro_name).trim_start();
436437
match trim_left_preserve_layout(macro_raw, shape.indent, &context.config) {
437438
Some(macro_body) => Some(format!("{} {}", macro_name, macro_body)),
438439
None => Some(format!("{} {}", macro_name, macro_raw)),

tests/target/issue-3439.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use repro::my_macro;
2+
3+
#[my_macro]
4+
xyz! abc {
5+
let a = 1;
6+
}

0 commit comments

Comments
 (0)