-
Notifications
You must be signed in to change notification settings - Fork 906
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
[Feature Request] Attempt to format brace macros as Block #3445
Comments
In the issue #3434, formatting of such macros is not wanted. Maybe there could be a configuration option to toggle formatting of brace macros. Edit: Actually, it was proposed to extend the skip attribute to prevent formatting a macro #3434 (comment) |
A configuration option or an attribute to explicitly enable formatting the inside of a macro with a specific name would be incredibly useful :) |
#[rustfmt::noskip] perhaps? |
Building DSL code requires macro block formatting ... |
I think when rustfmt sees a macro block, it should check the contents to see if it's valid Rust syntax. If yes, format it as Rust code. If not, leave it alone (under the assumption that it's a different non-Rust language). The HTML in #3434 is not valid Rust syntax, so it would not be changed. But most uses of macro blocks (the OP, |
Going to close this in an effort to consolidate duplicative threads.
The fundamental progress with this is that there's overlap between arg tokens that can be parsed as valid Rust syntax but actually are not, and applying the valid-Rust formatting rules to them can, and has, actually been a problem when using other call delims, with the only viable resolution being to either switch to the brace delim or adding the skip attribute on the call. It's simply not possible for rustfmt to ever be able to safely make that assumption, which is why a categorical approach is not viable. Something like the more explicit opt-in approaches that have been discussed elsewhere is probably the best middle ground |
For instance,
Removing this conditional in
rewrite_macro_inner
gets most of the way there, but leaves things likeUse
statements unformatted:The text was updated successfully, but these errors were encountered: