Weird new-line that does not shrink line width
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Version: rustfmt 1.8.0-nightly (75530e9f72 2025-03-18)
In my Wasmi project I have got the following Rust line of code:
/// Executes an [`Instruction::CallImported`].
pub fn execute_call_imported<T>(
&mut self,
store: &mut Store<T>,
results: RegSpan,
func: index::Func,
) -> Result<(), Error> {
let func = self.get_func(func);
_ = self.execute_call_imported_impl::<marker::NestedCall, T>(store, Some(results), &func)?;
Ok(())
}
And rustfmt decided to re-format this the assignment line to this:
_ =
self.execute_call_imported_impl::<marker::NestedCall, T>(store, Some(results), &func)?;
Note that rustfmt probably did this to reduce the line-width, however, given that _ = is so short and we are using 4 whitespaces for indentation, this change did not actually reduce the line's width and just introduced an unnecessary new-line which also made to code less readable in my opinion.
PR where I first saw this: https://github.com/wasmi-labs/wasmi/pull/1398
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 formatting shown in the issue with rustfmt 1.8.0-nightly using the provided Rust snippet. Compare the original assignment line with rustfmt's output and trace the line-width decision that moves _ = onto its own line; done means the formatter no longer introduces that unnecessary break when it does not reduce the line width.
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
- 45/100