Skip to content

Commit 711c91d

Browse files
committed
Remove HirCollector::map.
Because `rustc_middle::hir::map::Map` is a trivial wrapper around `TyCtxt`, and `HirCollector` has a `TyCtxt` field.
1 parent 701ccd3 commit 711c91d

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/librustdoc/doctest.rs

-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ pub(crate) fn run(
186186

187187
let mut collector = CreateRunnableDocTests::new(options, opts);
188188
let hir_collector = HirCollector::new(
189-
tcx.hir(),
190189
ErrorCodes::from(compiler.sess.opts.unstable_features.is_nightly_build()),
191190
enable_per_target_ignores,
192191
tcx,

src/librustdoc/doctest/rust.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc_data_structures::fx::FxHashSet;
66
use rustc_data_structures::sync::Lrc;
77
use rustc_hir::def_id::{CRATE_DEF_ID, LocalDefId};
88
use rustc_hir::{self as hir, CRATE_HIR_ID, intravisit};
9-
use rustc_middle::hir::map::Map;
109
use rustc_middle::hir::nested_filter;
1110
use rustc_middle::ty::TyCtxt;
1211
use rustc_resolve::rustdoc::span_of_fragments;
@@ -63,27 +62,21 @@ impl DocTestVisitor for RustCollector {
6362
}
6463

6564
pub(super) struct HirCollector<'tcx> {
66-
map: Map<'tcx>,
6765
codes: ErrorCodes,
6866
tcx: TyCtxt<'tcx>,
6967
enable_per_target_ignores: bool,
7068
collector: RustCollector,
7169
}
7270

7371
impl<'tcx> HirCollector<'tcx> {
74-
pub fn new(
75-
map: Map<'tcx>,
76-
codes: ErrorCodes,
77-
enable_per_target_ignores: bool,
78-
tcx: TyCtxt<'tcx>,
79-
) -> Self {
72+
pub fn new(codes: ErrorCodes, enable_per_target_ignores: bool, tcx: TyCtxt<'tcx>) -> Self {
8073
let collector = RustCollector {
8174
source_map: tcx.sess.psess.clone_source_map(),
8275
cur_path: vec![],
8376
position: DUMMY_SP,
8477
tests: vec![],
8578
};
86-
Self { map, codes, enable_per_target_ignores, tcx, collector }
79+
Self { codes, enable_per_target_ignores, tcx, collector }
8780
}
8881

8982
pub fn collect_crate(mut self) -> Vec<ScrapedDocTest> {
@@ -142,13 +135,13 @@ impl<'tcx> intravisit::Visitor<'tcx> for HirCollector<'tcx> {
142135
type NestedFilter = nested_filter::All;
143136

144137
fn nested_visit_map(&mut self) -> Self::Map {
145-
self.map
138+
self.tcx.hir()
146139
}
147140

148141
fn visit_item(&mut self, item: &'tcx hir::Item<'_>) {
149142
let name = match &item.kind {
150143
hir::ItemKind::Impl(impl_) => {
151-
rustc_hir_pretty::id_to_string(&self.map, impl_.self_ty.hir_id)
144+
rustc_hir_pretty::id_to_string(&self.tcx.hir(), impl_.self_ty.hir_id)
152145
}
153146
_ => item.ident.to_string(),
154147
};

0 commit comments

Comments
 (0)