Hanging when formatting a decently sized math expression
Open
Nobody has claimed this yet.
A-binary-ops
A-expressions
A-performance
C-bug
I-slow
S-has-mcve
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
I am porting some ancient Fortran code, which contains the following mess:
q1[n - 1] = d0*(j1*(phi/2.0+v*ds)).exp() / (
1.0 + v.powi(2) / (
w.powi(2) +
(
d0 / (1.0 + v.powi(2) / (
w.powi(2) + (d0 / (1.0 + v.powi(2) / (
w.powi(2) + (d0 / (1.0 + v.powi(2) / (
w.powi(2) + (d0 / (1.0 + v.powi(2) / (
w.powi(2) + (d0 / (1.0 + v.powi(2) / (
w.powi(2) + d0.powi(2)
).sqrt())).powi(2)
).sqrt())).powi(2)
).sqrt())).powi(2)
).sqrt())).powi(2)
).sqrt())).powi(2)
).sqrt()
);
When attempting to format this code, rustfmt appears to run indefinitely.
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 hang with the nested Rust expression in the issue body and determine which formatting stage fails to complete. Trace the relevant rustfmt formatting path from that input; done means the expression formats and rustfmt terminates reliably rather than running indefinitely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- performance, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100