I've written a library and a small example program using the library. The example wouldn't compile until I increased the type_length_limit
by several orders of magnitude, after which it took 20min to compile. I've managed to get this down to 5min by fiddling with the library API to make it a bit less generic, but that's still impractically long and I don't know what to try next.
I've written a lot of generic/async code before and this is far from the first time I've had this problem. For me at least, exploding compile times always correlate with exploding type lengths, so I need a way to find out where these massively complicated types are coming from.
The compiler's error message isn't much help here:
error: reached the type-length limit while instantiating `std::future::from_generator::<[s...td::future::Future, ()}]>, ()}]>`
|
= note: consider adding a `#![type_length_limit="109605624"]` attribute to your crate
error: aborting due to previous error
Is there some way to get it to not truncate the name of the type? Even if the fully-expanded type is a million lines long I could still pipe cargo's output to a file (or use less
) and have a look at what the type actually is. Then maybe I could figure out where it's getting instantiated.
Are there any secret compiler options to do this? If so, the error message should probably suggest them to the user. More generally, are there any planned features to help users debug these kinds of problems (assuming that exploding type-complexity problems are inherent to rust's design and will be around forever)?