-
Notifications
You must be signed in to change notification settings - Fork 888
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
Warn on line overflow when macro formatting fails #5706
base: master
Are you sure you want to change the base?
Conversation
@smoelius thanks for the PR. I haven't reviewed this yet but I wanted to quickly address a few things:
As mentioned in #5700 (comment) PR #3768 originally introduced these changes. We need to make sure we understand why that PR added those lines so we can determine if it's safe to just outright remove those lines.
The clippy repo is independant from rustfmt and not under the per-view of the rustfmt team. Feel free to open up a follow up PR there if you'd like but clippy isn't relevant here.
Just want to call out that rustfmt can't format those macros because they don't currently parse, which is related to why adding those lines to the
|
tests/config/issue_5700.toml
Outdated
match_block_trailing_comma = true | ||
wrap_comments = true | ||
edition = "2021" | ||
# error_on_line_overflow = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this commented out?
@ytmimi I incorporated your feedback. I agree it is much cleaner without the config file. I will try to look into #3768. In the meantime, I have converted the PR to a draft, since, e.g., @calebcartwright wants time to review the issue. |
@smoelius Thanks for continuing to help look into this. Based on #5700 (comment), if we decide that the current behavior is accurate, then the simplest solution is to update the docs for error_on_line_overflow to mention that we won't alert users when unformattable macros overflow. |
Do you have a sense for how hard it would be to address the When you wrote:
that suggested to me the fix might be non-trivial. |
I think only the |
Fixes #5700 by removing these lines:
rustfmt/src/macros.rs
Lines 138 to 141 in 34f9ca2
Re:
I'm not sure what's required here.
All of rustfmt's tests pass with those lines removed.
This change will require changes to Clippy. At least the following files are affected:
Most of the affected lines appear to be
declare_lint_pass!
orimpl_lint_pass!
invocations, e.g.:https://github.com/rust-lang/rust-clippy/blob/113c704d225c63c1a0eec29cfa9478b7537e7d73/clippy_lints/src/let_underscore.rs#L131
I would be happy to submit the PR to Clippy to fix those files.
Beyond Clippy, there do appear to be repos that use
error_on_line_overflow=true
"in the wild":https://grep.app/search?q=error_on_line_overflow%20%2A%3D%20%2Atrue®exp=true&filter[lang][0]=TOML
But since this an opt-in feature that is explicitly unstable, maybe it's okay to change its behavior(?).
r? @ytmimi