Best effort on long lines
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Input file:
fn main() {
aaaaaaaaaaaaaaaaaaaaa :: bbbbbbbbbbbbbbbbbb :: ccccccccccccccccccccccccccccccccccccccc :: dddddddddddddddddddd ( eeeeeeeeeeeeeeeeeeee :: ffffffffffffffffffff ( ggggggggg ( hhhhhhhhhhhhhhhh ) , iiiiiiiii ( jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj ) ) );
}
As of current master (c0e616bc1d19eb9b08a5db2f265b8332569e7259), cargo run --manifest-path path/to/rustfmt/Cargo.toml --release --bin rustfmt <main.rs leaves the long line in this file unchanged.
Shortening the input line such that it can fit within rustfmt's default max_width produces good formatting, as expected:
fn main() {
bbbbbbbbbbbbbbbbbb::ccccccccccccccccccccccccccccccccccccccc::dddddddddddddddddddd(
eeeeeeeeeeeeeeeeeeee::ffffffffffffffffffff(
ggggggggg(hhhhhhhhhhhhhhhh),
iiiiiiiii(jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj),
),
);
}
If I configure max_width = 1000, I get correct but very wide formatting, as expected:
fn main() {
aaaaaaaaaaaaaaaaaaaaa::bbbbbbbbbbbbbbbbbb::ccccccccccccccccccccccccccccccccccccccc::dddddddddddddddddddd(eeeeeeeeeeeeeeeeeeee::ffffffffffffffffffff(ggggggggg(hhhhhhhhhhhhhhhh), iiiiiiiii(jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj)));
}
Is there anything I can set to end up with best-effort formatting, even for content wider than max_width, rather than leaving long lines totally unformatted? Here is what I would want:
fn main() {
aaaaaaaaaaaaaaaaaaaaa::bbbbbbbbbbbbbbbbbb::ccccccccccccccccccccccccccccccccccccccc::dddddddddddddddddddd(
eeeeeeeeeeeeeeeeeeee::ffffffffffffffffffff(
ggggggggg(hhhhhhhhhhhhhhhh),
iiiiiiiii(jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj),
),
);
}
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 case from main.rs with the rustfmt Cargo command shown in the issue, first at the default max_width and then at 1000. Compare the unchanged long line with the requested best-effort output. Done means rustfmt applies the demonstrated wrapping even when content exceeds max_width.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100