|
1 | 1 | 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}; |
3 | 3 | use rustc_data_structures::fx::FxHashMap; |
4 | | -use rustc_middle::ty::TyCtxt; |
5 | 4 | use rustc_span::source_map::SourceMap; |
6 | 5 | use rustc_span::{BytePos, Span}; |
7 | 6 |
|
8 | 7 | use crate::config::{OutputFormat, RenderOptions}; |
9 | 8 |
|
10 | 9 | /// It returns the expanded macros correspondence map. |
11 | 10 | pub(crate) fn source_macro_expansion( |
| 11 | + krate: &Crate, |
12 | 12 | render_options: &RenderOptions, |
13 | 13 | output_format: OutputFormat, |
14 | | - tcx: TyCtxt<'_>, |
| 14 | + source_map: &SourceMap, |
15 | 15 | ) -> FxHashMap<BytePos, Vec<ExpandedCode>> { |
16 | | - if render_options.generate_macro_expansion |
17 | | - && output_format == OutputFormat::Html |
| 16 | + if output_format == OutputFormat::Html |
18 | 17 | && !render_options.html_no_source |
| 18 | + && render_options.generate_macro_expansion |
19 | 19 | { |
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 | | - |
25 | 20 | let mut expanded_visitor = ExpandedCodeVisitor { expanded_codes: Vec::new(), source_map }; |
26 | 21 | walk_crate(&mut expanded_visitor, krate); |
27 | 22 | expanded_visitor.compute_expanded() |
|
0 commit comments