Skip to content

Commit 701ccd3

Browse files
committed
Remove HirCollector::sess.
It's redundant w.r.t. `HirCollector::tcx`. This removes the unnecessary `'a` lifetime.
1 parent 7042c26 commit 701ccd3

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
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-
&compiler.sess,
190189
tcx.hir(),
191190
ErrorCodes::from(compiler.sess.opts.unstable_features.is_nightly_build()),
192191
enable_per_target_ignores,

src/librustdoc/doctest/rust.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use rustc_middle::hir::map::Map;
1010
use rustc_middle::hir::nested_filter;
1111
use rustc_middle::ty::TyCtxt;
1212
use rustc_resolve::rustdoc::span_of_fragments;
13-
use rustc_session::Session;
1413
use rustc_span::source_map::SourceMap;
1514
use rustc_span::{BytePos, DUMMY_SP, FileName, Pos, Span};
1615

@@ -63,30 +62,28 @@ impl DocTestVisitor for RustCollector {
6362
fn visit_header(&mut self, _name: &str, _level: u32) {}
6463
}
6564

66-
pub(super) struct HirCollector<'a, 'tcx> {
67-
sess: &'a Session,
65+
pub(super) struct HirCollector<'tcx> {
6866
map: Map<'tcx>,
6967
codes: ErrorCodes,
7068
tcx: TyCtxt<'tcx>,
7169
enable_per_target_ignores: bool,
7270
collector: RustCollector,
7371
}
7472

75-
impl<'a, 'tcx> HirCollector<'a, 'tcx> {
73+
impl<'tcx> HirCollector<'tcx> {
7674
pub fn new(
77-
sess: &'a Session,
7875
map: Map<'tcx>,
7976
codes: ErrorCodes,
8077
enable_per_target_ignores: bool,
8178
tcx: TyCtxt<'tcx>,
8279
) -> Self {
8380
let collector = RustCollector {
84-
source_map: sess.psess.clone_source_map(),
81+
source_map: tcx.sess.psess.clone_source_map(),
8582
cur_path: vec![],
8683
position: DUMMY_SP,
8784
tests: vec![],
8885
};
89-
Self { sess, map, codes, enable_per_target_ignores, tcx, collector }
86+
Self { map, codes, enable_per_target_ignores, tcx, collector }
9087
}
9188

9289
pub fn collect_crate(mut self) -> Vec<ScrapedDocTest> {
@@ -98,7 +95,7 @@ impl<'a, 'tcx> HirCollector<'a, 'tcx> {
9895
}
9996
}
10097

101-
impl<'a, 'tcx> HirCollector<'a, 'tcx> {
98+
impl<'tcx> HirCollector<'tcx> {
10299
fn visit_testable<F: FnOnce(&mut Self)>(
103100
&mut self,
104101
name: String,
@@ -108,7 +105,7 @@ impl<'a, 'tcx> HirCollector<'a, 'tcx> {
108105
) {
109106
let ast_attrs = self.tcx.hir().attrs(self.tcx.local_def_id_to_hir_id(def_id));
110107
if let Some(ref cfg) = ast_attrs.cfg(self.tcx, &FxHashSet::default()) {
111-
if !cfg.matches(&self.sess.psess, Some(self.tcx.features())) {
108+
if !cfg.matches(&self.tcx.sess.psess, Some(self.tcx.features())) {
112109
return;
113110
}
114111
}
@@ -141,7 +138,7 @@ impl<'a, 'tcx> HirCollector<'a, 'tcx> {
141138
}
142139
}
143140

144-
impl<'a, 'tcx> intravisit::Visitor<'tcx> for HirCollector<'a, 'tcx> {
141+
impl<'tcx> intravisit::Visitor<'tcx> for HirCollector<'tcx> {
145142
type NestedFilter = nested_filter::All;
146143

147144
fn nested_visit_map(&mut self) -> Self::Map {

0 commit comments

Comments
 (0)