fix 'Ident of macro+ident gets duplicated' error
This commit is contained in:
parent
06fc39f905
commit
40ff078abf
2 changed files with 8 additions and 1 deletions
|
|
@ -432,7 +432,8 @@ pub fn rewrite_macro_inner(
|
||||||
// the `macro_name!` and `{ /* macro_body */ }` but skip modifying
|
// the `macro_name!` and `{ /* macro_body */ }` but skip modifying
|
||||||
// anything in between the braces (for now).
|
// anything in between the braces (for now).
|
||||||
let snippet = context.snippet(mac.span);
|
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(¯o_name).trim_start();
|
||||||
match trim_left_preserve_layout(macro_raw, shape.indent, &context.config) {
|
match trim_left_preserve_layout(macro_raw, shape.indent, &context.config) {
|
||||||
Some(macro_body) => Some(format!("{} {}", macro_name, macro_body)),
|
Some(macro_body) => Some(format!("{} {}", macro_name, macro_body)),
|
||||||
None => Some(format!("{} {}", macro_name, macro_raw)),
|
None => Some(format!("{} {}", macro_name, macro_raw)),
|
||||||
|
|
|
||||||
6
tests/target/issue-3439.rs
Normal file
6
tests/target/issue-3439.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
use repro::my_macro;
|
||||||
|
|
||||||
|
#[my_macro]
|
||||||
|
xyz! abc {
|
||||||
|
let a = 1;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue