-
Notifications
You must be signed in to change notification settings - Fork 915
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
Failing when macro has %
in it, e.g. Tracing
#5516
Comments
Thanks for reaching out. What version of rustfmt are you using? (run |
reproducible examples: (add
expected output:
If you remove the |
We actually don't need to to add Formatting macros is tricky as they can contain arbitrary tokens and in this case the The only way to handle this would be to special case the |
I'm not familiar with the |
I'lll just add that while One can use any of the following with the first three being equivalent and the fourth through sixth being equivalent.
Only the first, third, and sixth (with In case this is done by making exception for the tracing macros, these are the macros I know of where this syntax is permissible: List of macros
|
I'm seeing this issue on rustfmt 1.7.0-nightly (f9b16149 2024-04-19), mainly with the |
@saffaffi the Issues with You won't notice the impact of rustfmt failing to format It would be best for you to open a new issue and provide a minimal code example that demonstrates the problem you're currently experiencing. |
I think I'm seeing this situation and wanted to add some info for others who may be searching for this like I was. I have a fn do_thing() {
// snip chain of calls ending in a `Result`
.map_err(|err| {
tracing::error!(err = %err, variable1 = ?variable1, variable2 = ?variable2, "========X");
err.into()
})
} The formatting for everything inside of the function (e.g., Other functions in this file are unaffected even when this function's formatting is broken. And as @ytmimi pointed out, the macro itself isn't formatted even when the rest of the surrounding formatting is working (which is understandable). Here's my $ rustfmt --version
rustfmt 1.8.0-stable (4eb161250e 2025-03-15) |
Here's a sample code:
this uses a macro from
tracing
to create theSpan
. However the%
in there makesrustfmt
fail.The text was updated successfully, but these errors were encountered: