Formatting with `format_strings=true` can result in warning from rustc
Open
Nobody has claimed this yet.
only-with-option
P-low
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
The following few lines show the issue:
# Write config and a file with a multi-line string
$ echo -e 'format_strings = true\nmax_width = 100' > rustfmt.toml
$ echo -e 'fn main() { let _about_message = "An experimental VCS
To get started, see the tutorial at https://github.com/martinvonz/jj/blob/main/docs/tutorial.md.
Note that `jj <command> --help` gives more verbose help than `jj <command> -h` or `jj help <command>`."; }' > foo.rs
# Compilation succeeds without warnings before formatting
$ rustc foo.rs
# Format the file
$ rustfmt foo.rs
# Compilation produces a warning after formatting
$ rustc foo.rs
warning: multiple lines skipped by escaped newline
--> foo.rs:4:97
|
4 | To get started, see the tutorial at https://github.com/martinvonz/jj/blob/main/docs/tutorial.md.\
| _________________________________________________________________________________________________^
5 | |
6 | |
7 | | Note that `jj <command> --help` gives more verbose help than `jj <command> -h` or `jj help \
| |_ skipping everything up to and including this point
warning: 1 warning emitted
The second line of the string can be shortened to well under 100 characters and even under 70 characters and it will still reproduce.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the warning using the rustfmt.toml configuration and multiline string in foo.rs, then run rustc before and after rustfmt. Trace the formatting path for format_strings=true and escaped newlines. Done means rustfmt preserves valid formatting without causing the reported rustc warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100