Resolve documentation links in rustc and store the results in metadata

This commit implements MCP https://github.com/rust-lang/compiler-team/issues/584

It also removes code that is no longer used, and that includes code cloning resolver, so issue #83761 is fixed.
This commit is contained in:
Vadim Petrochenkov
2022-02-01 20:30:32 +08:00
parent a12d31d5a6
commit b62b82aef4
28 changed files with 653 additions and 853 deletions

View File

@@ -31,6 +31,7 @@ extern crate tracing;
//
// Dependencies listed in Cargo.toml do not need `extern crate`.
extern crate pulldown_cmark;
extern crate rustc_ast;
extern crate rustc_ast_pretty;
extern crate rustc_attr;
@@ -792,22 +793,13 @@ fn main_args(at_args: &[String]) -> MainResult {
}
compiler.enter(|queries| {
// We need to hold on to the complete resolver, so we cause everything to be
// cloned for the analysis passes to use. Suboptimal, but necessary in the
// current architecture.
// FIXME(#83761): Resolver cloning can lead to inconsistencies between data in the
// two copies because one of the copies can be modified after `TyCtxt` construction.
let (resolver, resolver_caches) = {
let resolver_caches = {
let expansion = abort_on_err(queries.expansion(), sess);
let (krate, resolver, _) = &*expansion.borrow();
let resolver_caches = resolver.borrow_mut().access(|resolver| {
collect_intra_doc_links::early_resolve_intra_doc_links(
resolver,
krate,
render_options.document_private,
)
collect_intra_doc_links::early_resolve_intra_doc_links(resolver, krate)
});
(resolver.clone(), resolver_caches)
resolver_caches
};
if sess.diagnostic().has_errors_or_lint_errors().is_some() {
@@ -820,7 +812,6 @@ fn main_args(at_args: &[String]) -> MainResult {
let (krate, render_opts, mut cache) = sess.time("run_global_ctxt", || {
core::run_global_ctxt(
tcx,
resolver,
resolver_caches,
show_coverage,
render_options,