-
Notifications
You must be signed in to change notification settings - Fork 879
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 joins numbers separated by dot and whitespace #4807
Comments
Thanks for reaching out and including all the relevant information!
rustfmt's sole job is to reformat inputs according to the prescriptions codified in the Style Guide for each respective AST node; the developers probable intent with invalid code is completely orthogonal. In the case of the first snippet (the local assignment), the initializer expression is indeed parsed as field access so rustfmt correctly applies the formatting rules for field exprs. The fact that the resulting output happens to be a valid float is just a side effect of the nature of the developers original invalid syntax, and that's not a bug in rustfmt nor anything we can viably work around nor would we want to attempt to do so.
Understand your perspective here, but it's also true that rustfmt still only has very minimal support for formatting macros. I'd advise using brace delimiters instead ( |
Thanks for responding!
Fair enough. I had hoped this could be considered a bug that, if resolved, would incidentally fix my actual issue (the macro).
Oh right! Thank you for the advice, this works well enough for me! |
Describe the bug
Rustfmt joins numbers separated by whitespace and dots.
For example:
I think this is a bug because it changes the meaning of the program from field access (although erroneous) to float literal.
Although the user probably intended to write a float literal, I don't think it's the job of rustfmt to fix our errors (or is it?) 😃
This bothers me because in my particular case I have a macro that produces S-expressions in a syntax as close as possible to Scheme's.
Rustfmt changes a correct
into a broken
To Reproduce
Run Rustfmt on this playground
Expected behavior
I'd prefer if rustfmt did not change the first case, and it really should not break my macro use.
Meta
The text was updated successfully, but these errors were encountered: