Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitespace inside nested macro calls #10

Closed
Tuetuopay opened this issue Mar 25, 2022 · 0 comments · Fixed by #11
Closed

Whitespace inside nested macro calls #10

Tuetuopay opened this issue Mar 25, 2022 · 0 comments · Fixed by #11

Comments

@Tuetuopay
Copy link

When pretty-printing code that contains macros that nest, unparse will add spaces around all the inner macro's !:

println!("{}", prettyplease::unparse(&syn::parse_str("foo!(bar!(baz!(toto)));").unwrap()));

will print

foo!(bar ! (baz ! (toto)));

instead of the expected

foo!(bar!(baz!(toto)));

This is quite a common pattern in codegen where such invocations are commonplace:

include_file!(concat!(env!("OUT_DIR"), "/bindings.rs"));

Thanks for the great lib!

@dtolnay dtolnay changed the title Unparse fails on nested macros Whitespace inside nested macro calls Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant