Skip to content

Commit

Permalink
rm higher-ranked lifetimes from DocVisitor
Browse files Browse the repository at this point in the history
This allows the visitor to borrow from the visitees.
  • Loading branch information
Lukas Markeffsky committed Sep 25, 2024
1 parent b1745c3 commit 4facc1c
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/write_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ struct AliasedTypeImpl<'cache> {
type_aliases: Vec<(&'cache [Symbol], Item)>,
}

impl<'cx, 'cache> DocVisitor for TypeImplCollector<'cx, 'cache> {
impl<'cx, 'cache> DocVisitor<'_> for TypeImplCollector<'cx, 'cache> {
fn visit_item(&mut self, it: &Item) {
self.visit_item_recur(it);
let cache = self.cache;
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl LocalSourcesCollector<'_, '_> {
}
}

impl DocVisitor for LocalSourcesCollector<'_, '_> {
impl DocVisitor<'_> for LocalSourcesCollector<'_, '_> {
fn visit_item(&mut self, item: &clean::Item) {
self.add_local_source(item);

Expand All @@ -122,7 +122,7 @@ struct SourceCollector<'a, 'tcx> {
crate_name: &'a str,
}

impl DocVisitor for SourceCollector<'_, '_> {
impl DocVisitor<'_> for SourceCollector<'_, '_> {
fn visit_item(&mut self, item: &clean::Item) {
if !self.cx.include_sources {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/passes/calculate_doc_coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl<'a, 'b> CoverageCalculator<'a, 'b> {
}
}

impl<'a, 'b> DocVisitor for CoverageCalculator<'a, 'b> {
impl<'a, 'b> DocVisitor<'_> for CoverageCalculator<'a, 'b> {
fn visit_item(&mut self, i: &clean::Item) {
if !i.item_id.is_local() {
// non-local items are skipped because they can be out of the users control,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/passes/check_doc_test_visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) fn check_doc_test_visibility(krate: Crate, cx: &mut DocContext<'_>) -
krate
}

impl<'a, 'tcx> DocVisitor for DocTestVisibilityLinter<'a, 'tcx> {
impl<'a, 'tcx> DocVisitor<'_> for DocTestVisibilityLinter<'a, 'tcx> {
fn visit_item(&mut self, item: &Item) {
look_for_tests(self.cx, &item.doc_value(), item);

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ fn is_derive_trait_collision<T>(ns: &PerNS<Result<Vec<(Res, T)>, ResolutionFailu
}
}

impl<'a, 'tcx> DocVisitor for LinkCollector<'a, 'tcx> {
impl<'a, 'tcx> DocVisitor<'_> for LinkCollector<'a, 'tcx> {
fn visit_item(&mut self, item: &Item) {
self.resolve_links(item);
self.visit_item_recur(item)
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/passes/collect_trait_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ struct SyntheticImplCollector<'a, 'tcx> {
impls: Vec<Item>,
}

impl<'a, 'tcx> DocVisitor for SyntheticImplCollector<'a, 'tcx> {
impl<'a, 'tcx> DocVisitor<'_> for SyntheticImplCollector<'a, 'tcx> {
fn visit_item(&mut self, i: &Item) {
if i.is_struct() || i.is_enum() || i.is_union() {
// FIXME(eddyb) is this `doc(hidden)` check needed?
Expand All @@ -256,7 +256,7 @@ impl<'cache> ItemAndAliasCollector<'cache> {
}
}

impl<'cache> DocVisitor for ItemAndAliasCollector<'cache> {
impl<'cache> DocVisitor<'_> for ItemAndAliasCollector<'cache> {
fn visit_item(&mut self, i: &Item) {
self.items.insert(i.item_id);

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/passes/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub(crate) fn run_lints(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
krate
}

impl<'a, 'tcx> DocVisitor for Linter<'a, 'tcx> {
impl<'a, 'tcx> DocVisitor<'_> for Linter<'a, 'tcx> {
fn visit_item(&mut self, item: &Item) {
let Some(hir_id) = DocContext::as_local_hir_id(self.cx.tcx, item.item_id) else {
// If non-local, no need to check anything.
Expand Down
12 changes: 6 additions & 6 deletions src/librustdoc/visit.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::clean::*;

pub(crate) trait DocVisitor: Sized {
fn visit_item(&mut self, item: &Item) {
pub(crate) trait DocVisitor<'a>: Sized {
fn visit_item(&mut self, item: &'a Item) {
self.visit_item_recur(item)
}

/// don't override!
fn visit_inner_recur(&mut self, kind: &ItemKind) {
fn visit_inner_recur(&mut self, kind: &'a ItemKind) {
match kind {
StrippedItem(..) => unreachable!(),
ModuleItem(i) => {
Expand Down Expand Up @@ -47,18 +47,18 @@ pub(crate) trait DocVisitor: Sized {
}

/// don't override!
fn visit_item_recur(&mut self, item: &Item) {
fn visit_item_recur(&mut self, item: &'a Item) {
match &item.kind {
StrippedItem(i) => self.visit_inner_recur(&*i),
_ => self.visit_inner_recur(&item.kind),
}
}

fn visit_mod(&mut self, m: &Module) {
fn visit_mod(&mut self, m: &'a Module) {
m.items.iter().for_each(|i| self.visit_item(i))
}

fn visit_crate(&mut self, c: &Crate) {
fn visit_crate(&mut self, c: &'a Crate) {
self.visit_item(&c.module);

for trait_ in c.external_traits.values() {
Expand Down

0 comments on commit 4facc1c

Please sign in to comment.