Description
Currently, rustdoc has its own data structure for basically everything in the compiler: librustdoc::clean::types
. Collecting these ahead of time is expensive (#74590 (comment)) and it would be better to instead calculate them on demand. This would reduce a ton of code duplication, speed up rustdoc, and hopefully fix bugs related to caching (#74879) and get rid of hacks like fake IDs (#75355).
On the other hand, it's really hard.
The basic idea is to, instead of discarding the TyCtxt
after run_core
, instead pass in TyCtxt
to render
. Then render
will calculate the info it needs as it comes up - possibly still with caching in DocContext
, but because this is on-demand it will be like cache.get().or_else(|| calculate_info())
, not cache.get().unwrap()
which is what leads to the bugs.
cc @rust-lang/rustdoc - is this something you're interested in?
cc @RDambrosio016, @Kixiron - this would break your idea to have librustdoc_render
be a separate crate from librustdoc
, because there would inherently be no stable interface: DocContext
would be returning rustc types directly.
cc @P1n3appl3 - this would require rewriting large parts of the JSON backend.