Skip to content
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

Conversation

hamirmahal
Copy link
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 review from a team as code owners 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
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
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
Member

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

@hamirmahal
Copy link
Contributor Author

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

@cwfitzgerald
Copy link
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
27 checks passed
@hamirmahal hamirmahal deleted the style/simplify-string-formatting-for-readability branch September 25, 2024 04:13
@@ -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:?}"
Copy link
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