Skip to content

Get rid of clean in rustdoc #76382

Description

@jyn514

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCE-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.I-compilememIssue: Problems and improvements with respect to memory usage during compilation.I-compiletimeIssue: Problems and improvements with respect to compile times.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions