rust-lang / rustfmt

Format Rust code
https://rust-lang.github.io/rustfmt/
Apache License 2.0
6.06k stars 892 forks source link

Rustfmt spins for hours on large serde-derived implementation #1301

Closed sfackler closed 7 years ago

sfackler commented 7 years ago

I was looking into an issue that someone asked about on #rust with a large struct (284 fields) and a serde Deserialize implementation. I ran it through cargo-expand, which calls into rustfmt 0.7.1, and ended up spinning for ~2 hours before I gave up and killed it. There is quite a lot of code here (20,356 lines) but it's fairly straightforward.

https://gist.github.com/sfackler/ffe9e7ee45f83dd50479020de960fa05

I think this is distinct from #1265 since there don't appear to be any large chains in the expanded output.

topecongiro commented 7 years ago

rustfmt could not parse the original file, so I have done s/$crate/krate/ and tested with rustfmt-nightly 0.2.13. rustfmt managed to format the file without an error, within 2 seconds 🦀

nrc commented 7 years ago

Thanks for testing!