-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
rustdoc: Stop cloning the resolver #83761
Copy link
Copy link
Closed
Labels
A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Rustdoc currently creates a copy of the resolver to use for intra-doc links:
rust/src/librustdoc/core.rs
Lines 350 to 354 in d474075
This is a Terrible, Horrible, No Good, Very Bad Idea. In particular, it causes rustdoc's copy of the resolver and the TyCtxt to disagree about what crates exist:
It's also distorting rustc_resolve, since not all of the outputs make sense to clone in the first place: #65625 (comment)
We should refactor rustdoc somehow to allow getting rid of
Resolver::clone_outputs. @petrochenkov suggests moving anything that needs to touch the resolver before HIR lowering: #68427 (comment).@petrochenkov what do you think about @eddyb's comment in #65625 (comment) ?
Would it be possible for
lower_to_hirto stop stealing the resolver?rust/compiler/rustc_interface/src/queries.rs
Line 227 in d474075
Then rustdoc wouldn't need to clone it in the first place, it could just call
queries.expansion().peek().1whenever it needs access to the resolver.See #68427 for previous discussion.
Implementation History
clean::Items before resolving intra-doc links: rustdoc: Store intra-doc links in Cache instead of on items directly #83833collect_intra_doc_links: rustdoc: Move crate loader to collect_intra_doc_links::early #84101preprocess_linkto also take into account the hacks forSelf::andcrate:rust/src/librustdoc/passes/collect_intra_doc_links.rs
Line 880 in ef52471
rust/src/librustdoc/passes/collect_intra_doc_links.rs
Lines 1124 to 1153 in ef52471