Skip to content

Commit 287cce2

Browse files
committed
Revert "[perf] rustdoc: Don't obtain early resolver unless --generate-macro-expansion"
This reverts commit 6b50bc5.
1 parent 6b50bc5 commit 287cce2

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/librustdoc/core.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,13 @@ pub(crate) fn run_global_ctxt(
340340
// (see https://github.com/rust-lang/rust/pull/73566#issuecomment-656954425),
341341
// so type-check everything other than function bodies in this crate before running lints.
342342

343-
let expanded_macros = source_macro_expansion(&render_options, output_format, tcx);
343+
let expanded_macros = {
344+
// We need for these variables to be removed to ensure that the `Crate` won't be "stolen"
345+
// anymore.
346+
let (_resolver, krate) = &*tcx.resolver_for_lowering().borrow();
347+
348+
source_macro_expansion(&krate, &render_options, output_format, tcx.sess.source_map())
349+
};
344350

345351
// NOTE: this does not call `tcx.analysis()` so that we won't
346352
// typeck function bodies or run the default rustc lints.

src/librustdoc/html/macro_expansion.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
use rustc_ast::visit::{Visitor, walk_crate, walk_expr, walk_item, walk_pat, walk_stmt};
2-
use rustc_ast::{Expr, Item, Pat, Stmt};
2+
use rustc_ast::{Crate, Expr, Item, Pat, Stmt};
33
use rustc_data_structures::fx::FxHashMap;
4-
use rustc_middle::ty::TyCtxt;
54
use rustc_span::source_map::SourceMap;
65
use rustc_span::{BytePos, Span};
76

87
use crate::config::{OutputFormat, RenderOptions};
98

109
/// It returns the expanded macros correspondence map.
1110
pub(crate) fn source_macro_expansion(
11+
krate: &Crate,
1212
render_options: &RenderOptions,
1313
output_format: OutputFormat,
14-
tcx: TyCtxt<'_>,
14+
source_map: &SourceMap,
1515
) -> FxHashMap<BytePos, Vec<ExpandedCode>> {
16-
if render_options.generate_macro_expansion
17-
&& output_format == OutputFormat::Html
16+
if output_format == OutputFormat::Html
1817
&& !render_options.html_no_source
18+
&& render_options.generate_macro_expansion
1919
{
20-
// We need for these variables to be removed to ensure that the `Crate` won't be "stolen"
21-
// anymore.
22-
let (_resolver, krate) = &*tcx.resolver_for_lowering().borrow();
23-
let source_map = tcx.sess.source_map();
24-
2520
let mut expanded_visitor = ExpandedCodeVisitor { expanded_codes: Vec::new(), source_map };
2621
walk_crate(&mut expanded_visitor, krate);
2722
expanded_visitor.compute_expanded()

0 commit comments

Comments
 (0)