Skip to content

Commit

Permalink
Remove HirCollector::sess.
Browse files Browse the repository at this point in the history
It's redundant w.r.t. `HirCollector::tcx`. This removes the unnecessary
`'a` lifetime.
  • Loading branch information
nnethercote committed Sep 25, 2024
1 parent 7042c26 commit 701ccd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 7 additions & 10 deletions src/librustdoc/doctest/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -63,30 +62,28 @@ 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>,
enable_per_target_ignores: bool,
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> {
Expand All @@ -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,
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 701ccd3

Please sign in to comment.