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

rustfmt didn't format macro #3704

Closed
LEXUGE opened this issue Jul 27, 2019 · 5 comments
Closed

rustfmt didn't format macro #3704

LEXUGE opened this issue Jul 27, 2019 · 5 comments
Labels

Comments

@LEXUGE
Copy link

LEXUGE commented Jul 27, 2019

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7309a87bb5e3598b7ca9e80fcb115d60

The code snippet above haven't been formatted by rustfmt.

I have tried remove the parse and use the ordinary way of writing that. However, it didn't change anything.

@topecongiro
Copy link
Contributor

We need to specify the following options to format macro_rules!:

format_macro_matchers = true
format_macro_bodies = true

And even then rustfmt may not be able to format certain macro_rules!, especially those with unusual syntax.

@LEXUGE
Copy link
Author

LEXUGE commented Aug 1, 2019

We need to specify the following options to format macro_rules!:

format_macro_matchers = true
format_macro_bodies = true

And even then rustfmt may not be able to format certain macro_rules!, especially those with unusual syntax.

According to the README of the rustfmt.toml, It is said that format_macro_bodies is set to true in default. But it takes no effect on that.
If the unusual syntax of the macro leads to such a situation, it will be a sad news for me.

@topecongiro
Copy link
Contributor

If the unusual syntax of the macro leads to such a situation, it will be a sad news for me.

I believe this is the case. rustfmt is only able to format macros with 'valid' syntax.

@LEXUGE
Copy link
Author

LEXUGE commented Aug 16, 2019

If the unusual syntax of the macro leads to such a situation, it will be a sad news for me.

I believe this is the case. rustfmt is only able to format macros with 'valid' syntax.

OK. thanks for your help.
So various 'invalid' favors which are created by proc macro would not be supported by rustfmt in the future? If so, I will close this issue for less disturbance for you guys.

@topecongiro
Copy link
Contributor

Sorry for the late reply. No, it won't be supported in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants