Skip to content

style: simplify string formatting for readability#6316

Merged
cwfitzgerald merged 2 commits intogfx-rs:trunkfrom
hamirmahal:style/simplify-string-formatting-for-readability
Sep 25, 2024
Merged

style: simplify string formatting for readability#6316
cwfitzgerald merged 2 commits intogfx-rs:trunkfrom
hamirmahal:style/simplify-string-formatting-for-readability

Conversation

@hamirmahal
Copy link
Copy Markdown
Contributor

Description
The goal of this pull request is to improve code readability and maintainability.

Testing
I ran cargo xtask test locally.

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@hamirmahal hamirmahal requested a review from a team September 23, 2024 17:25
@hamirmahal hamirmahal requested a review from a team as a code owner September 23, 2024 17:25
@hamirmahal hamirmahal changed the title Style/simplify string formatting for readability style: simplify string formatting for readability Sep 23, 2024
Copy link
Copy Markdown
Member

@cwfitzgerald cwfitzgerald left a 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

@a1phyr
Copy link
Copy Markdown
Contributor

a1phyr commented Sep 23, 2024

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.

@ErichDonGubler
Copy link
Copy Markdown
Member

I think we'd be open to follow-up work that set the lint to warn-by-default! 😀

@hamirmahal
Copy link
Copy Markdown
Contributor Author

Sure, do you want that follow-up work in this PR, or a separate one?

@cwfitzgerald
Copy link
Copy Markdown
Member

cwfitzgerald commented Sep 25, 2024

Let me merge this, then lets do a follow-up.

@cwfitzgerald cwfitzgerald merged commit 8e787eb into gfx-rs:trunk Sep 25, 2024
@hamirmahal hamirmahal deleted the style/simplify-string-formatting-for-readability branch September 25, 2024 04:13
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:?}"
Copy link
Copy Markdown
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants