Closed
Description
1.57.0 seems to have brought a pretty deep regression in compile times for deeply nested "decorator" types, such as futures' Stream
combinators.
This is a minimized version of kube-rs/kube#746.
Code
I tried this code:
use futures::{stream, StreamExt, TryStreamExt};
fn main() {
stream::empty::<Result<(), ()>>()
.inspect_ok(|_| ())
.inspect_ok(|_| ())
// .boxed()
.inspect_ok(|_| ())
.inspect_ok(|_| ())
.inspect_ok(|_| ())
.inspect_ok(|_| ())
.inspect_ok(|_| ())
// .boxed()
.inspect_ok(|_| ())
.inspect_ok(|_| ())
.inspect_ok(|_| ())
.inspect_ok(|_| ())
.inspect_ok(|_| ())
// .boxed()
.inspect_ok(|_| ())
.inspect_ok(|_| ())
.inspect_ok(|_| ());
}
In Rust 1.56.1, this builds in ~0.7s on my machine (excluding time spent compiling futures
and its dependencies).
In Rust 1.57.0 (and the latest nightly), this takes several minutes.
Curiously, boxing into a trait object (by uncommenting the .boxed()
calls) seems to act as a type checking boundary, and makes rustc 1.57.0 build it in ~0.55s.
Version it worked on
It most recently worked on: Rust 1.56.1
Version with regression
rustc --version --verbose
:
rustc 1.57.0 (f1edd0429 2021-11-29)
Backtrace
There was no crash, so there is no backtrace to report.