WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@eddyb
Copy link
Member

@eddyb eddyb commented Aug 8, 2025

There's an unfortunate rustfmt bug/limitation, where string literals that cross the max width breaks reformatting in everything it's nested in.

The resulting files were tested for reformatting ability by (un)indenting the entire file (e.g. Ctrl+A Tab Ctrl+S in VSCode), and inspecting the resulting diff - complete success leads to only whitespace changes in lines that are string \ continuations (because rustfmt doesn't touch those).

In fact, to ensure all instances are caught, I ended up doing this instead:

sed -E -i 's/^./ \0/' src/**.rs && cargo fmt --all && git diff

(sadly, macros also don't get reformatted, so this is a bit annoying to skim, but still useful)


You can see in the diff that there was some positive overall impact by looking for formatting changes that are not directly around the changed strings, but rather in nearby (sibling-ish) AST nodes.

@eddyb eddyb added this pull request to the merge queue Aug 10, 2025
Merged via the queue into Rust-GPU:main with commit 5ce8e28 Aug 10, 2025
6 checks passed
@eddyb eddyb deleted the fmt-overlong-str branch August 10, 2025 15:37
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.

2 participants