1
Fork 0

Remove HirCollector::sess.

It's redundant w.r.t. `HirCollector::tcx`. This removes the unnecessary
`'a` lifetime.
This commit is contained in:
Nicholas Nethercote 2024-09-16 09:11:30 +10:00
parent 7042c269c1
commit 701ccd3ead
2 changed files with 7 additions and 11 deletions

View file

@ -186,7 +186,6 @@ pub(crate) fn run(
let mut collector = CreateRunnableDocTests::new(options, opts);
let hir_collector = HirCollector::new(
&compiler.sess,
tcx.hir(),
ErrorCodes::from(compiler.sess.opts.unstable_features.is_nightly_build()),
enable_per_target_ignores,

View file

@ -10,7 +10,6 @@ use rustc_middle::hir::map::Map;
use rustc_middle::hir::nested_filter;
use rustc_middle::ty::TyCtxt;
use rustc_resolve::rustdoc::span_of_fragments;
use rustc_session::Session;
use rustc_span::source_map::SourceMap;
use rustc_span::{BytePos, DUMMY_SP, FileName, Pos, Span};
@ -63,8 +62,7 @@ impl DocTestVisitor for RustCollector {
fn visit_header(&mut self, _name: &str, _level: u32) {}
}
pub(super) struct HirCollector<'a, 'tcx> {
sess: &'a Session,
pub(super) struct HirCollector<'tcx> {
map: Map<'tcx>,
codes: ErrorCodes,
tcx: TyCtxt<'tcx>,
@ -72,21 +70,20 @@ pub(super) struct HirCollector<'a, 'tcx> {
collector: RustCollector,
}
impl<'a, 'tcx> HirCollector<'a, 'tcx> {
impl<'tcx> HirCollector<'tcx> {
pub fn new(
sess: &'a Session,
map: Map<'tcx>,
codes: ErrorCodes,
enable_per_target_ignores: bool,
tcx: TyCtxt<'tcx>,
) -> Self {
let collector = RustCollector {
source_map: sess.psess.clone_source_map(),
source_map: tcx.sess.psess.clone_source_map(),
cur_path: vec![],
position: DUMMY_SP,
tests: vec![],
};
Self { sess, map, codes, enable_per_target_ignores, tcx, collector }
Self { map, codes, enable_per_target_ignores, tcx, collector }
}
pub fn collect_crate(mut self) -> Vec<ScrapedDocTest> {
@ -98,7 +95,7 @@ impl<'a, 'tcx> HirCollector<'a, 'tcx> {
}
}
impl<'a, 'tcx> HirCollector<'a, 'tcx> {
impl<'tcx> HirCollector<'tcx> {
fn visit_testable<F: FnOnce(&mut Self)>(
&mut self,
name: String,
@ -108,7 +105,7 @@ impl<'a, 'tcx> HirCollector<'a, 'tcx> {
) {
let ast_attrs = self.tcx.hir().attrs(self.tcx.local_def_id_to_hir_id(def_id));
if let Some(ref cfg) = ast_attrs.cfg(self.tcx, &FxHashSet::default()) {
if !cfg.matches(&self.sess.psess, Some(self.tcx.features())) {
if !cfg.matches(&self.tcx.sess.psess, Some(self.tcx.features())) {
return;
}
}
@ -141,7 +138,7 @@ impl<'a, 'tcx> HirCollector<'a, 'tcx> {
}
}
impl<'a, 'tcx> intravisit::Visitor<'tcx> for HirCollector<'a, 'tcx> {
impl<'tcx> intravisit::Visitor<'tcx> for HirCollector<'tcx> {
type NestedFilter = nested_filter::All;
fn nested_visit_map(&mut self) -> Self::Map {