Formatting of consecutive vec! lines requires multiple runs
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
rustfmt requires multiple runs to generate consistent output for this input code:
fn zserio_read(&mut self, reader: &mut BitReader) -> Result<()> {
self.headers = vec![crate::reference_modules::parameter_passing::index_operator::block_header::BlockHeader::new(); headers_array_length];
self.blocks = vec![crate::reference_modules::parameter_passing::index_operator::block::Block::new(); blocks_array_length];
}
After a first pass the code is updated to this:
fn zserio_read(&mut self, reader: &mut BitReader) -> Result<()> {
self.headers = vec![crate::reference_modules::parameter_passing::index_operator::block_header::BlockHeader::new(); headers_array_length];
self.blocks =
vec![
crate::reference_modules::parameter_passing::index_operator::block::Block::new();
blocks_array_length
];
}
And after a second pass it moves the vec! invocation to the line with the assignment:
fn zserio_read(&mut self, reader: &mut BitReader) -> Result<()> {
self.headers = vec![crate::reference_modules::parameter_passing::index_operator::block_header::BlockHeader::new(); headers_array_length];
self.blocks = vec![
crate::reference_modules::parameter_passing::index_operator::block::Block::new();
blocks_array_length
];
}
after this rustfmt is happy an running it again creates no further changes.
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
Start by reproducing the reported two-pass behavior with the Rust snippet in the issue and compare the formatter's output after each run. Trace the formatting path for consecutive vec! invocations and assignment expressions; done means the input reaches stable output in one run and repeated formatting makes no further changes.
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