style: simplify string formatting for readability#6316
style: simplify string formatting for readability#6316cwfitzgerald merged 2 commits intogfx-rs:trunkfrom hamirmahal:style/simplify-string-formatting-for-readability
Conversation
cwfitzgerald
left a comment
There was a problem hiding this comment.
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. |
| 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.
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 testlocally.Checklist
cargo fmt.cargo clippy. If applicable, add:--target wasm32-unknown-unknown--target wasm32-unknown-emscriptencargo xtask testto run tests.CHANGELOG.md. See simple instructions inside file.