-
Notifications
You must be signed in to change notification settings - Fork 928
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
style: simplify string formatting for readability #6316
style: simplify string formatting for readability #6316
Conversation
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.
Nice, surprised clippy doesn't have a thing for that, actually
It does, but was moved from warn-by-default to allow-by-default because rust-analyzer didn't support them well at the time, which made them painful to have in a codebase. |
I think we'd be open to follow-up work that set the lint to warn-by-default! 😀 |
Sure, do you want that follow-up work in this PR, or a separate one? |
Let me merge this, then lets do a follow-up. |
@@ -186,8 +186,7 @@ impl Test<'_> { | |||
|
|||
if &expected_data[..] != contents { | |||
panic!( | |||
"Test expectation is not met!\nBuffer content was:\n{:?}\nbut expected:\n{:?}", | |||
contents, expected_data | |||
"Test expectation is not met!\nBuffer content was:\n{contents:?}\nbut expected:\n{expected_data:?}" |
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.
context: rustfmt
refuses to format runs of expressions with lines that exceed the default 100-column limit which it can't break up. We often run into this when we're writing shaders in string literals, or have a long diagnostic message we want to present.
issue(non-blocking): By lengthening this formatting spec. string literal to go past that limit here, we're making rustfmt
run into this case.
Since this is already merged, I'm gonna open a new PR and fix this and other cases up: #6349
I wish this weren't such a hard-to-detect problem; the only reason I recognize it is because I've done this dozens of times to myself.
Description
The goal of this pull request is to improve code readability and maintainability.
Testing
I ran
cargo xtask test
locally.Checklist
cargo fmt
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.