1
Fork 0

Overhaul the intravisit::Map trait.

First of all, note that `Map` has three different relevant meanings.
- The `intravisit::Map` trait.
- The `map::Map` struct.
- The `NestedFilter::Map` associated type.

The `intravisit::Map` trait is impl'd twice.
- For `!`, where the methods are all unreachable.
- For `map::Map`, which gets HIR stuff from the `TyCtxt`.

As part of getting rid of `map::Map`, this commit changes `impl
intravisit::Map for map::Map` to `impl intravisit::Map for TyCtxt`. It's
fairly straightforward except various things are renamed, because the
existing names would no longer have made sense.

- `trait intravisit::Map` becomes `trait intravisit::HirTyCtxt`, so named
  because it gets some HIR stuff from a `TyCtxt`.
- `NestedFilter::Map` assoc type becomes `NestedFilter::MaybeTyCtxt`,
  because it's always `!` or `TyCtxt`.
- `Visitor::nested_visit_map` becomes `Visitor::maybe_tcx`.

I deliberately made the new trait and associated type names different to
avoid the old `type Map: Map` situation, which I found confusing. We now
have `type MaybeTyCtxt: HirTyCtxt`.
This commit is contained in:
Nicholas Nethercote 2025-02-03 14:42:01 +11:00
parent f86f7ad5f2
commit 661f99ba03
59 changed files with 208 additions and 210 deletions

View file

@ -348,13 +348,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
expr: Option<&'hir hir::Expr<'hir>>, expr: Option<&'hir hir::Expr<'hir>>,
pat: Option<&'hir hir::Pat<'hir>>, pat: Option<&'hir hir::Pat<'hir>>,
parent_pat: Option<&'hir hir::Pat<'hir>>, parent_pat: Option<&'hir hir::Pat<'hir>>,
hir: rustc_middle::hir::map::Map<'hir>, tcx: TyCtxt<'hir>,
} }
impl<'hir> Visitor<'hir> for ExpressionFinder<'hir> { impl<'hir> Visitor<'hir> for ExpressionFinder<'hir> {
type NestedFilter = OnlyBodies; type NestedFilter = OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.hir self.tcx
} }
fn visit_expr(&mut self, e: &'hir hir::Expr<'hir>) { fn visit_expr(&mut self, e: &'hir hir::Expr<'hir>) {
@ -396,7 +396,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
expr: None, expr: None,
pat: None, pat: None,
parent_pat: None, parent_pat: None,
hir, tcx: self.infcx.tcx,
}; };
finder.visit_expr(expr); finder.visit_expr(expr);
if let Some(span) = span if let Some(span) = span
@ -2455,7 +2455,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let body_expr = tcx.hir_body(body_id).value; let body_expr = tcx.hir_body(body_id).value;
struct ClosureFinder<'hir> { struct ClosureFinder<'hir> {
hir: rustc_middle::hir::map::Map<'hir>, tcx: TyCtxt<'hir>,
borrow_span: Span, borrow_span: Span,
res: Option<(&'hir hir::Expr<'hir>, &'hir hir::Closure<'hir>)>, res: Option<(&'hir hir::Expr<'hir>, &'hir hir::Closure<'hir>)>,
/// The path expression with the `borrow_span` span /// The path expression with the `borrow_span` span
@ -2464,8 +2464,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
impl<'hir> Visitor<'hir> for ClosureFinder<'hir> { impl<'hir> Visitor<'hir> for ClosureFinder<'hir> {
type NestedFilter = OnlyBodies; type NestedFilter = OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.hir self.tcx
} }
fn visit_expr(&mut self, ex: &'hir hir::Expr<'hir>) { fn visit_expr(&mut self, ex: &'hir hir::Expr<'hir>) {
@ -2491,7 +2491,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
// Find the closure that most tightly wraps `capture_kind_span` // Find the closure that most tightly wraps `capture_kind_span`
let mut finder = let mut finder =
ClosureFinder { hir, borrow_span: capture_kind_span, res: None, error_path: None }; ClosureFinder { tcx, borrow_span: capture_kind_span, res: None, error_path: None };
finder.visit_expr(body_expr); finder.visit_expr(body_expr);
let Some((closure_expr, closure)) = finder.res else { return }; let Some((closure_expr, closure)) = finder.res else { return };

View file

@ -256,8 +256,8 @@ impl<'tcx> BorrowExplanation<'tcx> {
impl<'hir> rustc_hir::intravisit::Visitor<'hir> for FindLetExpr<'hir> { impl<'hir> rustc_hir::intravisit::Visitor<'hir> for FindLetExpr<'hir> {
type NestedFilter = rustc_middle::hir::nested_filter::OnlyBodies; type NestedFilter = rustc_middle::hir::nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_expr(&mut self, expr: &'hir hir::Expr<'hir>) { fn visit_expr(&mut self, expr: &'hir hir::Expr<'hir>) {
if let hir::ExprKind::If(cond, _conseq, _alt) if let hir::ExprKind::If(cond, _conseq, _alt)

View file

@ -7,7 +7,7 @@ use rustc_hir::intravisit::Visitor;
use rustc_hir::{self as hir, CaptureBy, ExprKind, HirId, Node}; use rustc_hir::{self as hir, CaptureBy, ExprKind, HirId, Node};
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::mir::*; use rustc_middle::mir::*;
use rustc_middle::ty::{self, Ty}; use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_mir_dataflow::move_paths::{LookupResult, MovePathIndex}; use rustc_mir_dataflow::move_paths::{LookupResult, MovePathIndex};
use rustc_span::{BytePos, ExpnKind, MacroKind, Span}; use rustc_span::{BytePos, ExpnKind, MacroKind, Span};
use rustc_trait_selection::error_reporting::traits::FindExprBySpan; use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
@ -690,7 +690,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
/// make it bind by reference instead (if possible) /// make it bind by reference instead (if possible)
struct BindingFinder<'tcx> { struct BindingFinder<'tcx> {
typeck_results: &'tcx ty::TypeckResults<'tcx>, typeck_results: &'tcx ty::TypeckResults<'tcx>,
hir: rustc_middle::hir::map::Map<'tcx>, tcx: TyCtxt<'tcx>,
/// Input: the span of the pattern we're finding bindings in /// Input: the span of the pattern we're finding bindings in
pat_span: Span, pat_span: Span,
/// Input: the spans of the bindings we're providing suggestions for /// Input: the spans of the bindings we're providing suggestions for
@ -709,8 +709,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
impl<'tcx> Visitor<'tcx> for BindingFinder<'tcx> { impl<'tcx> Visitor<'tcx> for BindingFinder<'tcx> {
type NestedFilter = rustc_middle::hir::nested_filter::OnlyBodies; type NestedFilter = rustc_middle::hir::nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.hir self.tcx
} }
fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) -> Self::Result { fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) -> Self::Result {
@ -782,7 +782,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let typeck_results = self.infcx.tcx.typeck(self.mir_def_id()); let typeck_results = self.infcx.tcx.typeck(self.mir_def_id());
let mut finder = BindingFinder { let mut finder = BindingFinder {
typeck_results, typeck_results,
hir, tcx: self.infcx.tcx,
pat_span, pat_span,
binding_spans, binding_spans,
found_pat: false, found_pat: false,

View file

@ -18,7 +18,7 @@
//! within one another. //! within one another.
//! - Example: Examine each expression to look for its type and do some check or other. //! - Example: Examine each expression to look for its type and do some check or other.
//! - How: Implement `intravisit::Visitor` and override the `NestedFilter` type to //! - How: Implement `intravisit::Visitor` and override the `NestedFilter` type to
//! `nested_filter::OnlyBodies` (and implement `nested_visit_map`), and use //! `nested_filter::OnlyBodies` (and implement `maybe_tcx`), and use
//! `tcx.hir().visit_all_item_likes_in_crate(&mut visitor)`. Within your //! `tcx.hir().visit_all_item_likes_in_crate(&mut visitor)`. Within your
//! `intravisit::Visitor` impl, implement methods like `visit_expr()` (don't forget to invoke //! `intravisit::Visitor` impl, implement methods like `visit_expr()` (don't forget to invoke
//! `intravisit::walk_expr()` to keep walking the subparts). //! `intravisit::walk_expr()` to keep walking the subparts).
@ -30,7 +30,7 @@
//! - Example: Lifetime resolution, which wants to bring lifetimes declared on the //! - Example: Lifetime resolution, which wants to bring lifetimes declared on the
//! impl into scope while visiting the impl-items, and then back out again. //! impl into scope while visiting the impl-items, and then back out again.
//! - How: Implement `intravisit::Visitor` and override the `NestedFilter` type to //! - How: Implement `intravisit::Visitor` and override the `NestedFilter` type to
//! `nested_filter::All` (and implement `nested_visit_map`). Walk your crate with //! `nested_filter::All` (and implement `maybe_tcx`). Walk your crate with
//! `tcx.hir().walk_toplevel_module(visitor)` invoked on `tcx.hir().krate()`. //! `tcx.hir().walk_toplevel_module(visitor)` invoked on `tcx.hir().krate()`.
//! - Pro: Visitor methods for any kind of HIR node, not just item-like things. //! - Pro: Visitor methods for any kind of HIR node, not just item-like things.
//! - Pro: Preserves nesting information //! - Pro: Preserves nesting information
@ -106,41 +106,43 @@ impl<'a> FnKind<'a> {
} }
} }
/// An abstract representation of the HIR `rustc_middle::hir::map::Map`. /// HIR things retrievable from `TyCtxt`, avoiding an explicit dependence on
pub trait Map<'hir> { /// `TyCtxt`. The only impls are for `!` (where these functions are never
/// called) and `TyCtxt` (in `rustc_middle`).
pub trait HirTyCtxt<'hir> {
/// Retrieves the `Node` corresponding to `id`. /// Retrieves the `Node` corresponding to `id`.
fn hir_node(&self, hir_id: HirId) -> Node<'hir>; fn hir_node(&self, hir_id: HirId) -> Node<'hir>;
fn body(&self, id: BodyId) -> &'hir Body<'hir>; fn hir_body(&self, id: BodyId) -> &'hir Body<'hir>;
fn item(&self, id: ItemId) -> &'hir Item<'hir>; fn hir_item(&self, id: ItemId) -> &'hir Item<'hir>;
fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir>; fn hir_trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir>;
fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir>; fn hir_impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir>;
fn foreign_item(&self, id: ForeignItemId) -> &'hir ForeignItem<'hir>; fn hir_foreign_item(&self, id: ForeignItemId) -> &'hir ForeignItem<'hir>;
} }
// Used when no map is actually available, forcing manual implementation of nested visitors. // Used when no tcx is actually available, forcing manual implementation of nested visitors.
impl<'hir> Map<'hir> for ! { impl<'hir> HirTyCtxt<'hir> for ! {
fn hir_node(&self, _: HirId) -> Node<'hir> { fn hir_node(&self, _: HirId) -> Node<'hir> {
unreachable!(); unreachable!();
} }
fn body(&self, _: BodyId) -> &'hir Body<'hir> { fn hir_body(&self, _: BodyId) -> &'hir Body<'hir> {
unreachable!(); unreachable!();
} }
fn item(&self, _: ItemId) -> &'hir Item<'hir> { fn hir_item(&self, _: ItemId) -> &'hir Item<'hir> {
unreachable!(); unreachable!();
} }
fn trait_item(&self, _: TraitItemId) -> &'hir TraitItem<'hir> { fn hir_trait_item(&self, _: TraitItemId) -> &'hir TraitItem<'hir> {
unreachable!(); unreachable!();
} }
fn impl_item(&self, _: ImplItemId) -> &'hir ImplItem<'hir> { fn hir_impl_item(&self, _: ImplItemId) -> &'hir ImplItem<'hir> {
unreachable!(); unreachable!();
} }
fn foreign_item(&self, _: ForeignItemId) -> &'hir ForeignItem<'hir> { fn hir_foreign_item(&self, _: ForeignItemId) -> &'hir ForeignItem<'hir> {
unreachable!(); unreachable!();
} }
} }
pub mod nested_filter { pub mod nested_filter {
use super::Map; use super::HirTyCtxt;
/// Specifies what nested things a visitor wants to visit. By "nested /// Specifies what nested things a visitor wants to visit. By "nested
/// things", we are referring to bits of HIR that are not directly embedded /// things", we are referring to bits of HIR that are not directly embedded
@ -155,7 +157,7 @@ pub mod nested_filter {
/// See the comments at [`rustc_hir::intravisit`] for more details on the overall /// See the comments at [`rustc_hir::intravisit`] for more details on the overall
/// visit strategy. /// visit strategy.
pub trait NestedFilter<'hir> { pub trait NestedFilter<'hir> {
type Map: Map<'hir>; type MaybeTyCtxt: HirTyCtxt<'hir>;
/// Whether the visitor visits nested "item-like" things. /// Whether the visitor visits nested "item-like" things.
/// E.g., item, impl-item. /// E.g., item, impl-item.
@ -171,10 +173,10 @@ pub mod nested_filter {
/// ///
/// Use this if you are only walking some particular kind of tree /// Use this if you are only walking some particular kind of tree
/// (i.e., a type, or fn signature) and you don't want to thread a /// (i.e., a type, or fn signature) and you don't want to thread a
/// HIR map around. /// `tcx` around.
pub struct None(()); pub struct None(());
impl NestedFilter<'_> for None { impl NestedFilter<'_> for None {
type Map = !; type MaybeTyCtxt = !;
const INTER: bool = false; const INTER: bool = false;
const INTRA: bool = false; const INTRA: bool = false;
} }
@ -199,18 +201,18 @@ use nested_filter::NestedFilter;
/// to monitor future changes to `Visitor` in case a new method with a /// to monitor future changes to `Visitor` in case a new method with a
/// new default implementation gets introduced.) /// new default implementation gets introduced.)
pub trait Visitor<'v>: Sized { pub trait Visitor<'v>: Sized {
// This type should not be overridden, it exists for convenient usage as `Self::Map`. // This type should not be overridden, it exists for convenient usage as `Self::MaybeTyCtxt`.
type Map: Map<'v> = <Self::NestedFilter as NestedFilter<'v>>::Map; type MaybeTyCtxt: HirTyCtxt<'v> = <Self::NestedFilter as NestedFilter<'v>>::MaybeTyCtxt;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Nested items. // Nested items.
/// Override this type to control which nested HIR are visited; see /// Override this type to control which nested HIR are visited; see
/// [`NestedFilter`] for details. If you override this type, you /// [`NestedFilter`] for details. If you override this type, you
/// must also override [`nested_visit_map`](Self::nested_visit_map). /// must also override [`maybe_tcx`](Self::maybe_tcx).
/// ///
/// **If for some reason you want the nested behavior, but don't /// **If for some reason you want the nested behavior, but don't
/// have a `Map` at your disposal:** then override the /// have a `tcx` at your disposal:** then override the
/// `visit_nested_XXX` methods. If a new `visit_nested_XXX` variant is /// `visit_nested_XXX` methods. If a new `visit_nested_XXX` variant is
/// added in the future, it will cause a panic which can be detected /// added in the future, it will cause a panic which can be detected
/// and fixed appropriately. /// and fixed appropriately.
@ -222,9 +224,9 @@ pub trait Visitor<'v>: Sized {
/// If `type NestedFilter` is set to visit nested items, this method /// If `type NestedFilter` is set to visit nested items, this method
/// must also be overridden to provide a map to retrieve nested items. /// must also be overridden to provide a map to retrieve nested items.
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
panic!( panic!(
"nested_visit_map must be implemented or consider using \ "maybe_tcx must be implemented or consider using \
`type NestedFilter = nested_filter::None` (the default)" `type NestedFilter = nested_filter::None` (the default)"
); );
} }
@ -236,10 +238,10 @@ pub trait Visitor<'v>: Sized {
/// "deep" visit patterns described at /// "deep" visit patterns described at
/// [`rustc_hir::intravisit`]. The only reason to override /// [`rustc_hir::intravisit`]. The only reason to override
/// this method is if you want a nested pattern but cannot supply a /// this method is if you want a nested pattern but cannot supply a
/// [`Map`]; see `nested_visit_map` for advice. /// `TyCtxt`; see `maybe_tcx` for advice.
fn visit_nested_item(&mut self, id: ItemId) -> Self::Result { fn visit_nested_item(&mut self, id: ItemId) -> Self::Result {
if Self::NestedFilter::INTER { if Self::NestedFilter::INTER {
let item = self.nested_visit_map().item(id); let item = self.maybe_tcx().hir_item(id);
try_visit!(self.visit_item(item)); try_visit!(self.visit_item(item));
} }
Self::Result::output() Self::Result::output()
@ -250,7 +252,7 @@ pub trait Visitor<'v>: Sized {
/// method. /// method.
fn visit_nested_trait_item(&mut self, id: TraitItemId) -> Self::Result { fn visit_nested_trait_item(&mut self, id: TraitItemId) -> Self::Result {
if Self::NestedFilter::INTER { if Self::NestedFilter::INTER {
let item = self.nested_visit_map().trait_item(id); let item = self.maybe_tcx().hir_trait_item(id);
try_visit!(self.visit_trait_item(item)); try_visit!(self.visit_trait_item(item));
} }
Self::Result::output() Self::Result::output()
@ -261,7 +263,7 @@ pub trait Visitor<'v>: Sized {
/// method. /// method.
fn visit_nested_impl_item(&mut self, id: ImplItemId) -> Self::Result { fn visit_nested_impl_item(&mut self, id: ImplItemId) -> Self::Result {
if Self::NestedFilter::INTER { if Self::NestedFilter::INTER {
let item = self.nested_visit_map().impl_item(id); let item = self.maybe_tcx().hir_impl_item(id);
try_visit!(self.visit_impl_item(item)); try_visit!(self.visit_impl_item(item));
} }
Self::Result::output() Self::Result::output()
@ -272,7 +274,7 @@ pub trait Visitor<'v>: Sized {
/// method. /// method.
fn visit_nested_foreign_item(&mut self, id: ForeignItemId) -> Self::Result { fn visit_nested_foreign_item(&mut self, id: ForeignItemId) -> Self::Result {
if Self::NestedFilter::INTER { if Self::NestedFilter::INTER {
let item = self.nested_visit_map().foreign_item(id); let item = self.maybe_tcx().hir_foreign_item(id);
try_visit!(self.visit_foreign_item(item)); try_visit!(self.visit_foreign_item(item));
} }
Self::Result::output() Self::Result::output()
@ -283,7 +285,7 @@ pub trait Visitor<'v>: Sized {
/// `Self::NestedFilter`. /// `Self::NestedFilter`.
fn visit_nested_body(&mut self, id: BodyId) -> Self::Result { fn visit_nested_body(&mut self, id: BodyId) -> Self::Result {
if Self::NestedFilter::INTRA { if Self::NestedFilter::INTRA {
let body = self.nested_visit_map().body(id); let body = self.maybe_tcx().hir_body(id);
try_visit!(self.visit_body(body)); try_visit!(self.visit_body(body));
} }
Self::Result::output() Self::Result::output()

View file

@ -435,8 +435,8 @@ fn best_definition_site_of_opaque<'tcx>(
impl<'tcx> intravisit::Visitor<'tcx> for TaitConstraintLocator<'tcx> { impl<'tcx> intravisit::Visitor<'tcx> for TaitConstraintLocator<'tcx> {
type NestedFilter = nested_filter::All; type NestedFilter = nested_filter::All;
type Result = ControlFlow<(Span, LocalDefId)>; type Result = ControlFlow<(Span, LocalDefId)>;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) -> Self::Result { fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) -> Self::Result {
if let hir::ExprKind::Closure(closure) = ex.kind { if let hir::ExprKind::Closure(closure) = ex.kind {

View file

@ -277,8 +277,8 @@ fn reject_placeholder_type_signatures_in_item<'tcx>(
impl<'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'tcx> { impl<'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {

View file

@ -63,8 +63,8 @@ pub(crate) fn def_parents(tcx: TyCtxt<'_>) {
impl<'tcx> intravisit::Visitor<'tcx> for AnonConstFinder<'tcx> { impl<'tcx> intravisit::Visitor<'tcx> for AnonConstFinder<'tcx> {
type NestedFilter = nested_filter::All; type NestedFilter = nested_filter::All;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_anon_const(&mut self, c: &'tcx rustc_hir::AnonConst) { fn visit_anon_const(&mut self, c: &'tcx rustc_hir::AnonConst) {

View file

@ -422,8 +422,8 @@ enum NonLifetimeBinderAllowed {
impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_nested_body(&mut self, body: hir::BodyId) { fn visit_nested_body(&mut self, body: hir::BodyId) {

View file

@ -298,8 +298,8 @@ impl TaitConstraintLocator<'_> {
impl<'tcx> intravisit::Visitor<'tcx> for TaitConstraintLocator<'tcx> { impl<'tcx> intravisit::Visitor<'tcx> for TaitConstraintLocator<'tcx> {
type NestedFilter = nested_filter::All; type NestedFilter = nested_filter::All;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) { fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) {
if let hir::ExprKind::Closure(closure) = ex.kind { if let hir::ExprKind::Closure(closure) = ex.kind {
@ -441,8 +441,8 @@ impl RpitConstraintChecker<'_> {
impl<'tcx> intravisit::Visitor<'tcx> for RpitConstraintChecker<'tcx> { impl<'tcx> intravisit::Visitor<'tcx> for RpitConstraintChecker<'tcx> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) { fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) {
if let hir::ExprKind::Closure(closure) = ex.kind { if let hir::ExprKind::Closure(closure) = ex.kind {

View file

@ -24,8 +24,8 @@ use rustc_span::source_map::SourceMap;
use rustc_span::{FileName, Ident, Span, Symbol, kw}; use rustc_span::{FileName, Ident, Span, Symbol, kw};
use {rustc_ast as ast, rustc_hir as hir}; use {rustc_ast as ast, rustc_hir as hir};
pub fn id_to_string(map: &dyn rustc_hir::intravisit::Map<'_>, hir_id: HirId) -> String { pub fn id_to_string(cx: &dyn rustc_hir::intravisit::HirTyCtxt<'_>, hir_id: HirId) -> String {
to_string(&map, |s| s.print_node(map.hir_node(hir_id))) to_string(&cx, |s| s.print_node(cx.hir_node(hir_id)))
} }
pub enum AnnNode<'a> { pub enum AnnNode<'a> {
@ -54,15 +54,15 @@ pub trait PpAnn {
fn post(&self, _state: &mut State<'_>, _node: AnnNode<'_>) {} fn post(&self, _state: &mut State<'_>, _node: AnnNode<'_>) {}
} }
impl PpAnn for &dyn rustc_hir::intravisit::Map<'_> { impl PpAnn for &dyn rustc_hir::intravisit::HirTyCtxt<'_> {
fn nested(&self, state: &mut State<'_>, nested: Nested) { fn nested(&self, state: &mut State<'_>, nested: Nested) {
match nested { match nested {
Nested::Item(id) => state.print_item(self.item(id)), Nested::Item(id) => state.print_item(self.hir_item(id)),
Nested::TraitItem(id) => state.print_trait_item(self.trait_item(id)), Nested::TraitItem(id) => state.print_trait_item(self.hir_trait_item(id)),
Nested::ImplItem(id) => state.print_impl_item(self.impl_item(id)), Nested::ImplItem(id) => state.print_impl_item(self.hir_impl_item(id)),
Nested::ForeignItem(id) => state.print_foreign_item(self.foreign_item(id)), Nested::ForeignItem(id) => state.print_foreign_item(self.hir_foreign_item(id)),
Nested::Body(id) => state.print_expr(self.body(id).value), Nested::Body(id) => state.print_expr(self.hir_body(id).value),
Nested::BodyParamPat(id, i) => state.print_pat(self.body(id).params[i].pat), Nested::BodyParamPat(id, i) => state.print_pat(self.hir_body(id).params[i].pat),
} }
} }
} }

View file

@ -2725,8 +2725,8 @@ struct FindClosureArg<'tcx> {
impl<'tcx> Visitor<'tcx> for FindClosureArg<'tcx> { impl<'tcx> Visitor<'tcx> for FindClosureArg<'tcx> {
type NestedFilter = rustc_middle::hir::nested_filter::All; type NestedFilter = rustc_middle::hir::nested_filter::All;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) { fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {

View file

@ -174,8 +174,8 @@ impl<'tcx> IfThisChanged<'tcx> {
impl<'tcx> Visitor<'tcx> for IfThisChanged<'tcx> { impl<'tcx> Visitor<'tcx> for IfThisChanged<'tcx> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {

View file

@ -455,8 +455,8 @@ impl<'tcx> FindAllAttrs<'tcx> {
impl<'tcx> intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> { impl<'tcx> intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> {
type NestedFilter = nested_filter::All; type NestedFilter = nested_filter::All;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_attribute(&mut self, attr: &'tcx Attribute) { fn visit_attribute(&mut self, attr: &'tcx Attribute) {

View file

@ -84,8 +84,8 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
/// Because lints are scoped lexically, we want to walk nested /// Because lints are scoped lexically, we want to walk nested
/// items in the context of the outer item, so enable /// items in the context of the outer item, so enable
/// deep-walking. /// deep-walking.
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.context.tcx.hir() self.context.tcx
} }
fn visit_nested_body(&mut self, body_id: hir::BodyId) { fn visit_nested_body(&mut self, body_id: hir::BodyId) {

View file

@ -270,8 +270,8 @@ impl<'tcx> LintLevelsBuilder<'_, LintLevelQueryMap<'tcx>> {
impl<'tcx> Visitor<'tcx> for LintLevelsBuilder<'_, LintLevelQueryMap<'tcx>> { impl<'tcx> Visitor<'tcx> for LintLevelsBuilder<'_, LintLevelQueryMap<'tcx>> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.provider.tcx.hir() self.provider.tcx
} }
fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) { fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
@ -365,8 +365,8 @@ impl<'tcx> LintLevelMaximum<'tcx> {
impl<'tcx> Visitor<'tcx> for LintLevelMaximum<'tcx> { impl<'tcx> Visitor<'tcx> for LintLevelMaximum<'tcx> {
type NestedFilter = nested_filter::All; type NestedFilter = nested_filter::All;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
/// FIXME(blyxyas): In a future revision, we should also graph #![allow]s, /// FIXME(blyxyas): In a future revision, we should also graph #![allow]s,

View file

@ -2410,7 +2410,6 @@ pub(crate) fn provide(providers: &mut Providers) {
/// use a different method for pretty-printing. Ideally this function /// use a different method for pretty-printing. Ideally this function
/// should only ever be used as a fallback. /// should only ever be used as a fallback.
pub fn rendered_const<'tcx>(tcx: TyCtxt<'tcx>, body: &hir::Body<'_>, def_id: LocalDefId) -> String { pub fn rendered_const<'tcx>(tcx: TyCtxt<'tcx>, body: &hir::Body<'_>, def_id: LocalDefId) -> String {
let hir = tcx.hir();
let value = body.value; let value = body.value;
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq)]
@ -2467,7 +2466,7 @@ pub fn rendered_const<'tcx>(tcx: TyCtxt<'tcx>, body: &hir::Body<'_>, def_id: Loc
// Otherwise we prefer pretty-printing to get rid of extraneous whitespace, comments and // Otherwise we prefer pretty-printing to get rid of extraneous whitespace, comments and
// other formatting artifacts. // other formatting artifacts.
Literal | Simple => id_to_string(&hir, body.id().hir_id), Literal | Simple => id_to_string(&tcx, body.id().hir_id),
// FIXME: Omit the curly braces if the enclosing expression is an array literal // FIXME: Omit the curly braces if the enclosing expression is an array literal
// with a repeated element (an `ExprKind::Repeat`) as in such case it // with a repeated element (an `ExprKind::Repeat`) as in such case it

View file

@ -1034,35 +1034,35 @@ impl<'hir> Map<'hir> {
} }
} }
impl<'hir> intravisit::Map<'hir> for Map<'hir> { impl<'tcx> intravisit::HirTyCtxt<'tcx> for TyCtxt<'tcx> {
fn hir_node(&self, hir_id: HirId) -> Node<'hir> { fn hir_node(&self, hir_id: HirId) -> Node<'tcx> {
self.tcx.hir_node(hir_id) (*self).hir_node(hir_id)
} }
fn body(&self, id: BodyId) -> &'hir Body<'hir> { fn hir_body(&self, id: BodyId) -> &'tcx Body<'tcx> {
self.tcx.hir_body(id) (*self).hir_body(id)
} }
fn item(&self, id: ItemId) -> &'hir Item<'hir> { fn hir_item(&self, id: ItemId) -> &'tcx Item<'tcx> {
self.tcx.hir_item(id) (*self).hir_item(id)
} }
fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> { fn hir_trait_item(&self, id: TraitItemId) -> &'tcx TraitItem<'tcx> {
self.tcx.hir_trait_item(id) (*self).hir_trait_item(id)
} }
fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir> { fn hir_impl_item(&self, id: ImplItemId) -> &'tcx ImplItem<'tcx> {
self.tcx.hir_impl_item(id) (*self).hir_impl_item(id)
} }
fn foreign_item(&self, id: ForeignItemId) -> &'hir ForeignItem<'hir> { fn hir_foreign_item(&self, id: ForeignItemId) -> &'tcx ForeignItem<'tcx> {
self.tcx.hir_foreign_item(id) (*self).hir_foreign_item(id)
} }
} }
impl<'tcx> pprust_hir::PpAnn for TyCtxt<'tcx> { impl<'tcx> pprust_hir::PpAnn for TyCtxt<'tcx> {
fn nested(&self, state: &mut pprust_hir::State<'_>, nested: pprust_hir::Nested) { fn nested(&self, state: &mut pprust_hir::State<'_>, nested: pprust_hir::Nested) {
pprust_hir::PpAnn::nested(&(&self.hir() as &dyn intravisit::Map<'_>), state, nested) pprust_hir::PpAnn::nested(&(self as &dyn intravisit::HirTyCtxt<'_>), state, nested)
} }
} }
@ -1349,8 +1349,8 @@ impl<'tcx> ItemCollector<'tcx> {
impl<'hir> Visitor<'hir> for ItemCollector<'hir> { impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
type NestedFilter = nested_filter::All; type NestedFilter = nested_filter::All;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_item(&mut self, item: &'hir Item<'hir>) { fn visit_item(&mut self, item: &'hir Item<'hir>) {

View file

@ -1,5 +1,7 @@
use rustc_hir::intravisit::nested_filter::NestedFilter; use rustc_hir::intravisit::nested_filter::NestedFilter;
use crate::ty::TyCtxt;
/// Do not visit nested item-like things, but visit nested things /// Do not visit nested item-like things, but visit nested things
/// that are inside of an item-like. /// that are inside of an item-like.
/// ///
@ -12,8 +14,8 @@ use rustc_hir::intravisit::nested_filter::NestedFilter;
/// and to have the visitor that visits the contents of each item /// and to have the visitor that visits the contents of each item
/// using this setting. /// using this setting.
pub struct OnlyBodies(()); pub struct OnlyBodies(());
impl<'hir> NestedFilter<'hir> for OnlyBodies { impl<'tcx> NestedFilter<'tcx> for OnlyBodies {
type Map = crate::hir::map::Map<'hir>; type MaybeTyCtxt = TyCtxt<'tcx>;
const INTER: bool = false; const INTER: bool = false;
const INTRA: bool = true; const INTRA: bool = true;
} }
@ -24,8 +26,8 @@ impl<'hir> NestedFilter<'hir> for OnlyBodies {
/// process everything within their lexical context. Typically you /// process everything within their lexical context. Typically you
/// kick off the visit by doing `walk_krate()`. /// kick off the visit by doing `walk_krate()`.
pub struct All(()); pub struct All(());
impl<'hir> NestedFilter<'hir> for All { impl<'tcx> NestedFilter<'tcx> for All {
type Map = crate::hir::map::Map<'hir>; type MaybeTyCtxt = TyCtxt<'tcx>;
const INTER: bool = true; const INTER: bool = true;
const INTRA: bool = true; const INTRA: bool = true;
} }

View file

@ -10,7 +10,6 @@ mod unexpand;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::intravisit::{Visitor, walk_expr};
use rustc_middle::hir::map::Map;
use rustc_middle::hir::nested_filter; use rustc_middle::hir::nested_filter;
use rustc_middle::mir::coverage::{ use rustc_middle::mir::coverage::{
CoverageKind, DecisionInfo, FunctionCoverageInfo, Mapping, MappingKind, CoverageKind, DecisionInfo, FunctionCoverageInfo, Mapping, MappingKind,
@ -348,7 +347,7 @@ fn extract_hole_spans_from_hir<'tcx>(
hir_body: &hir::Body<'tcx>, hir_body: &hir::Body<'tcx>,
) -> Vec<Span> { ) -> Vec<Span> {
struct HolesVisitor<'hir, F> { struct HolesVisitor<'hir, F> {
hir: Map<'hir>, tcx: TyCtxt<'hir>,
visit_hole_span: F, visit_hole_span: F,
} }
@ -360,8 +359,8 @@ fn extract_hole_spans_from_hir<'tcx>(
/// items contained within them. /// items contained within them.
type NestedFilter = nested_filter::All; type NestedFilter = nested_filter::All;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.hir self.tcx
} }
fn visit_item(&mut self, item: &'hir hir::Item<'hir>) { fn visit_item(&mut self, item: &'hir hir::Item<'hir>) {
@ -388,7 +387,7 @@ fn extract_hole_spans_from_hir<'tcx>(
let mut hole_spans = vec![]; let mut hole_spans = vec![];
let mut visitor = HolesVisitor { let mut visitor = HolesVisitor {
hir: tcx.hir(), tcx,
visit_hole_span: |hole_span| { visit_hole_span: |hole_span| {
// Discard any holes that aren't directly visible within the body span. // Discard any holes that aren't directly visible within the body span.
if body_span.contains(hole_span) && body_span.eq_ctxt(hole_span) { if body_span.contains(hole_span) && body_span.eq_ctxt(hole_span) {

View file

@ -2606,8 +2606,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> { impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_item(&mut self, item: &'tcx Item<'tcx>) { fn visit_item(&mut self, item: &'tcx Item<'tcx>) {

View file

@ -105,8 +105,8 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> {
impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> { impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_nested_item(&mut self, id: hir::ItemId) { fn visit_nested_item(&mut self, id: hir::ItemId) {

View file

@ -129,8 +129,8 @@ impl<'tcx> LibFeatureCollector<'tcx> {
impl<'tcx> Visitor<'tcx> for LibFeatureCollector<'tcx> { impl<'tcx> Visitor<'tcx> for LibFeatureCollector<'tcx> {
type NestedFilter = nested_filter::All; type NestedFilter = nested_filter::All;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_attribute(&mut self, attr: &'tcx Attribute) { fn visit_attribute(&mut self, attr: &'tcx Attribute) {

View file

@ -87,8 +87,8 @@ pub(crate) fn provide(providers: &mut Providers) {
impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> { impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_anon_const(&mut self, c: &'hir hir::AnonConst) { fn visit_anon_const(&mut self, c: &'hir hir::AnonConst) {

View file

@ -259,8 +259,8 @@ struct CheckNakedAsmInNakedFn<'tcx> {
impl<'tcx> Visitor<'tcx> for CheckNakedAsmInNakedFn<'tcx> { impl<'tcx> Visitor<'tcx> for CheckNakedAsmInNakedFn<'tcx> {
type NestedFilter = OnlyBodies; type NestedFilter = OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {

View file

@ -394,8 +394,8 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
/// deep-walking. /// deep-walking.
type NestedFilter = nested_filter::All; type NestedFilter = nested_filter::All;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_item(&mut self, i: &'tcx Item<'tcx>) { fn visit_item(&mut self, i: &'tcx Item<'tcx>) {
@ -616,8 +616,8 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> { impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_item(&mut self, i: &'tcx Item<'tcx>) { fn visit_item(&mut self, i: &'tcx Item<'tcx>) {
@ -756,8 +756,8 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
/// Because stability levels are scoped lexically, we want to walk /// Because stability levels are scoped lexically, we want to walk
/// nested items in the context of the outer item, so enable /// nested items in the context of the outer item, so enable
/// deep-walking. /// deep-walking.
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {

View file

@ -1202,8 +1202,8 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for FindInferSourceVisitor<'a, 'tcx> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tecx.tcx.hir() self.tecx.tcx
} }
fn visit_local(&mut self, local: &'tcx LetStmt<'tcx>) { fn visit_local(&mut self, local: &'tcx LetStmt<'tcx>) {

View file

@ -3,7 +3,6 @@ use core::ops::ControlFlow;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::{self, Visitor, VisitorExt}; use rustc_hir::intravisit::{self, Visitor, VisitorExt};
use rustc_hir::{self as hir, AmbigArg}; use rustc_hir::{self as hir, AmbigArg};
use rustc_middle::hir::map::Map;
use rustc_middle::hir::nested_filter; use rustc_middle::hir::nested_filter;
use rustc_middle::middle::resolve_bound_vars as rbv; use rustc_middle::middle::resolve_bound_vars as rbv;
use rustc_middle::ty::{self, Region, TyCtxt}; use rustc_middle::ty::{self, Region, TyCtxt};
@ -70,8 +69,8 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
type Result = ControlFlow<&'tcx hir::Ty<'tcx>>; type Result = ControlFlow<&'tcx hir::Ty<'tcx>>;
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_ty(&mut self, arg: &'tcx hir::Ty<'tcx, AmbigArg>) -> Self::Result { fn visit_ty(&mut self, arg: &'tcx hir::Ty<'tcx, AmbigArg>) -> Self::Result {
@ -176,8 +175,8 @@ impl<'tcx> Visitor<'tcx> for TyPathVisitor<'tcx> {
type Result = ControlFlow<()>; type Result = ControlFlow<()>;
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Map<'tcx> { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) -> Self::Result { fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) -> Self::Result {

View file

@ -133,8 +133,8 @@ struct TypeParamSpanVisitor<'tcx> {
impl<'tcx> Visitor<'tcx> for TypeParamSpanVisitor<'tcx> { impl<'tcx> Visitor<'tcx> for TypeParamSpanVisitor<'tcx> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_ty(&mut self, arg: &'tcx hir::Ty<'tcx, AmbigArg>) { fn visit_ty(&mut self, arg: &'tcx hir::Ty<'tcx, AmbigArg>) {

View file

@ -68,8 +68,8 @@ impl<'hir> FindExprBySpan<'hir> {
impl<'v> Visitor<'v> for FindExprBySpan<'v> { impl<'v> Visitor<'v> for FindExprBySpan<'v> {
type NestedFilter = rustc_middle::hir::nested_filter::OnlyBodies; type NestedFilter = rustc_middle::hir::nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_expr(&mut self, ex: &'v hir::Expr<'v>) { fn visit_expr(&mut self, ex: &'v hir::Expr<'v>) {

View file

@ -703,7 +703,7 @@ fn build_module_items(
pub(crate) fn print_inlined_const(tcx: TyCtxt<'_>, did: DefId) -> String { pub(crate) fn print_inlined_const(tcx: TyCtxt<'_>, did: DefId) -> String {
if let Some(did) = did.as_local() { if let Some(did) = did.as_local() {
let hir_id = tcx.local_def_id_to_hir_id(did); let hir_id = tcx.local_def_id_to_hir_id(did);
rustc_hir_pretty::id_to_string(&tcx.hir(), hir_id) rustc_hir_pretty::id_to_string(&tcx, hir_id)
} else { } else {
tcx.rendered_const(did).clone() tcx.rendered_const(did).clone()
} }

View file

@ -464,10 +464,10 @@ impl<'tcx> EmitIgnoredResolutionErrors<'tcx> {
impl<'tcx> Visitor<'tcx> for EmitIgnoredResolutionErrors<'tcx> { impl<'tcx> Visitor<'tcx> for EmitIgnoredResolutionErrors<'tcx> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
// We need to recurse into nested closures, // We need to recurse into nested closures,
// since those will fallback to the parent for type checking. // since those will fallback to the parent for type checking.
self.tcx.hir() self.tcx
} }
fn visit_path(&mut self, path: &Path<'tcx>, _id: HirId) { fn visit_path(&mut self, path: &Path<'tcx>, _id: HirId) {

View file

@ -147,14 +147,14 @@ impl HirCollector<'_> {
impl<'tcx> intravisit::Visitor<'tcx> for HirCollector<'tcx> { impl<'tcx> intravisit::Visitor<'tcx> for HirCollector<'tcx> {
type NestedFilter = nested_filter::All; type NestedFilter = nested_filter::All;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_item(&mut self, item: &'tcx hir::Item<'_>) { fn visit_item(&mut self, item: &'tcx hir::Item<'_>) {
let name = match &item.kind { let name = match &item.kind {
hir::ItemKind::Impl(impl_) => { hir::ItemKind::Impl(impl_) => {
rustc_hir_pretty::id_to_string(&self.tcx.hir(), impl_.self_ty.hir_id) rustc_hir_pretty::id_to_string(&self.tcx, impl_.self_ty.hir_id)
} }
_ => item.ident.to_string(), _ => item.ident.to_string(),
}; };

View file

@ -221,8 +221,8 @@ impl SpanMapVisitor<'_> {
impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> { impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> {
type NestedFilter = nested_filter::All; type NestedFilter = nested_filter::All;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_path(&mut self, path: &rustc_hir::Path<'tcx>, _id: HirId) { fn visit_path(&mut self, path: &rustc_hir::Path<'tcx>, _id: HirId) {

View file

@ -123,8 +123,8 @@ where
{ {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx().hir() self.cx.tcx()
} }
fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) { fn visit_expr(&mut self, ex: &'tcx hir::Expr<'tcx>) {

View file

@ -563,8 +563,8 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
impl<'tcx> Visitor<'tcx> for RustdocVisitor<'_, 'tcx> { impl<'tcx> Visitor<'tcx> for RustdocVisitor<'_, 'tcx> {
type NestedFilter = nested_filter::All; type NestedFilter = nested_filter::All;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
fn visit_item(&mut self, i: &'tcx hir::Item<'tcx>) { fn visit_item(&mut self, i: &'tcx hir::Item<'tcx>) {

View file

@ -437,8 +437,8 @@ impl<'tcx> Visitor<'tcx> for UnsafeVisitor<'_, 'tcx> {
walk_expr(self, expr) walk_expr(self, expr)
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }

View file

@ -1079,8 +1079,8 @@ impl<'tcx> Visitor<'tcx> for FindPanicUnwrap<'_, 'tcx> {
// Panics in const blocks will cause compilation to fail. // Panics in const blocks will cause compilation to fail.
fn visit_anon_const(&mut self, _: &'tcx AnonConst) {} fn visit_anon_const(&mut self, _: &'tcx AnonConst) {}
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }

View file

@ -241,8 +241,8 @@ impl<'tcx> Visitor<'tcx> for TypeWalker<'_, 'tcx> {
} }
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }

View file

@ -134,8 +134,8 @@ impl<'tcx> Visitor<'tcx> for SelfFinder<'_, 'tcx> {
type Result = ControlFlow<()>; type Result = ControlFlow<()>;
type NestedFilter = OnlyBodies; type NestedFilter = OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
fn visit_path(&mut self, path: &Path<'tcx>, _id: HirId) -> Self::Result { fn visit_path(&mut self, path: &Path<'tcx>, _id: HirId) -> Self::Result {

View file

@ -363,7 +363,7 @@ impl<'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'_, '_, 'tcx> {
walk_expr(self, e); walk_expr(self, e);
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }

View file

@ -223,8 +223,8 @@ struct SliceIndexLintingVisitor<'a, 'tcx> {
impl<'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'_, 'tcx> { impl<'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'_, 'tcx> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {

View file

@ -19,8 +19,8 @@ use rustc_hir::{
WherePredicateKind, lang_items, WherePredicateKind, lang_items,
}; };
use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::hir::map::Map;
use rustc_middle::hir::nested_filter as middle_nested_filter; use rustc_middle::hir::nested_filter as middle_nested_filter;
use rustc_middle::ty::TyCtxt;
use rustc_session::impl_lint_pass; use rustc_session::impl_lint_pass;
use rustc_span::Span; use rustc_span::Span;
use rustc_span::def_id::LocalDefId; use rustc_span::def_id::LocalDefId;
@ -582,7 +582,7 @@ impl<'tcx, F> Visitor<'tcx> for LifetimeChecker<'_, 'tcx, F>
where where
F: NestedFilter<'tcx>, F: NestedFilter<'tcx>,
{ {
type Map = Map<'tcx>; type MaybeTyCtxt = TyCtxt<'tcx>;
type NestedFilter = F; type NestedFilter = F;
// for lifetimes as parameters of generics // for lifetimes as parameters of generics
@ -628,8 +628,8 @@ where
self.lifetime_elision_impossible = false; self.lifetime_elision_impossible = false;
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }

View file

@ -240,8 +240,8 @@ impl<'tcx> Visitor<'tcx> for InitializeVisitor<'_, 'tcx> {
} }
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }

View file

@ -245,8 +245,8 @@ fn needs_mutable_borrow(cx: &LateContext<'_>, iter_expr: &IterExpr, loop_expr: &
impl<'tcx> Visitor<'tcx> for AfterLoopVisitor<'_, '_, 'tcx> { impl<'tcx> Visitor<'tcx> for AfterLoopVisitor<'_, '_, 'tcx> {
type NestedFilter = OnlyBodies; type NestedFilter = OnlyBodies;
type Result = ControlFlow<()>; type Result = ControlFlow<()>;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
fn visit_expr(&mut self, e: &'tcx Expr<'_>) -> Self::Result { fn visit_expr(&mut self, e: &'tcx Expr<'_>) -> Self::Result {
@ -288,8 +288,8 @@ fn needs_mutable_borrow(cx: &LateContext<'_>, iter_expr: &IterExpr, loop_expr: &
} }
impl<'tcx> Visitor<'tcx> for NestedLoopVisitor<'_, '_, 'tcx> { impl<'tcx> Visitor<'tcx> for NestedLoopVisitor<'_, '_, 'tcx> {
type NestedFilter = OnlyBodies; type NestedFilter = OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
fn visit_local(&mut self, l: &'tcx LetStmt<'_>) { fn visit_local(&mut self, l: &'tcx LetStmt<'_>) {

View file

@ -456,8 +456,8 @@ impl<'tcx> Visitor<'tcx> for UsedCountVisitor<'_, 'tcx> {
} }
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }

View file

@ -143,8 +143,8 @@ impl<'tcx> Visitor<'tcx> for UnwrapVisitor<'_, 'tcx> {
walk_path(self, path); walk_path(self, path);
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }
@ -174,7 +174,7 @@ impl<'tcx> Visitor<'tcx> for ReferenceVisitor<'_, 'tcx> {
rustc_hir::intravisit::walk_expr(self, expr) rustc_hir::intravisit::walk_expr(self, expr)
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }

View file

@ -89,8 +89,8 @@ struct CloneOrCopyVisitor<'cx, 'tcx> {
impl<'tcx> Visitor<'tcx> for CloneOrCopyVisitor<'_, 'tcx> { impl<'tcx> Visitor<'tcx> for CloneOrCopyVisitor<'_, 'tcx> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) { fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {

View file

@ -119,7 +119,7 @@ impl<'tcx> Visitor<'tcx> for MutArgVisitor<'_, 'tcx> {
walk_expr(self, expr); walk_expr(self, expr);
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }

View file

@ -583,8 +583,8 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &Body<'tcx>, args: &[
} }
impl<'tcx> Visitor<'tcx> for V<'_, 'tcx> { impl<'tcx> Visitor<'tcx> for V<'_, 'tcx> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
fn visit_anon_const(&mut self, _: &'tcx AnonConst) {} fn visit_anon_const(&mut self, _: &'tcx AnonConst) {}

View file

@ -241,8 +241,8 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClosureCall {
hir_visit::walk_expr(self, expr); hir_visit::walk_expr(self, expr);
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }
let mut closure_usage_count = ClosureUsageCount { cx, path, count: 0 }; let mut closure_usage_count = ClosureUsageCount { cx, path, count: 0 };

View file

@ -9,7 +9,6 @@ use rustc_hir::intravisit::{FnKind, Visitor, walk_body, walk_expr};
use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId, Item, ItemKind, Node, QPath, TyKind}; use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId, Item, ItemKind, Node, QPath, TyKind};
use rustc_hir_analysis::lower_ty; use rustc_hir_analysis::lower_ty;
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::hir::map::Map;
use rustc_middle::hir::nested_filter; use rustc_middle::hir::nested_filter;
use rustc_middle::ty::{self, AssocKind, Ty, TyCtxt}; use rustc_middle::ty::{self, AssocKind, Ty, TyCtxt};
use rustc_session::impl_lint_pass; use rustc_session::impl_lint_pass;
@ -275,7 +274,6 @@ fn is_default_method_on_current_ty<'tcx>(tcx: TyCtxt<'tcx>, qpath: QPath<'tcx>,
struct CheckCalls<'a, 'tcx> { struct CheckCalls<'a, 'tcx> {
cx: &'a LateContext<'tcx>, cx: &'a LateContext<'tcx>,
map: Map<'tcx>,
implemented_ty_id: DefId, implemented_ty_id: DefId,
method_span: Span, method_span: Span,
} }
@ -287,8 +285,8 @@ where
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
type Result = ControlFlow<()>; type Result = ControlFlow<()>;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.map self.cx.tcx
} }
fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) -> ControlFlow<()> { fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) -> ControlFlow<()> {
@ -380,7 +378,6 @@ impl UnconditionalRecursion {
{ {
let mut c = CheckCalls { let mut c = CheckCalls {
cx, cx,
map: cx.tcx.hir(),
implemented_ty_id, implemented_ty_id,
method_span, method_span,
}; };

View file

@ -101,8 +101,8 @@ impl<'tcx> Visitor<'tcx> for AsyncFnVisitor<'_, 'tcx> {
} }
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }

View file

@ -112,8 +112,8 @@ impl<'tcx> Visitor<'tcx> for PeekableVisitor<'_, 'tcx> {
type NestedFilter = OnlyBodies; type NestedFilter = OnlyBodies;
type Result = ControlFlow<()>; type Result = ControlFlow<()>;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) -> ControlFlow<()> { fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) -> ControlFlow<()> {

View file

@ -374,8 +374,8 @@ impl<'tcx> Visitor<'tcx> for UnwrappableVariablesVisitor<'_, 'tcx> {
} }
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }

View file

@ -277,7 +277,7 @@ impl<'tcx> Visitor<'tcx> for LintCollector<'_, 'tcx> {
} }
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx.hir()
} }
} }

View file

@ -249,8 +249,8 @@ impl<'tcx> Visitor<'tcx> for WaitFinder<'_, 'tcx> {
walk_expr(self, ex) walk_expr(self, ex)
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }

View file

@ -1370,8 +1370,8 @@ impl<'tcx> Visitor<'tcx> for ContainsName<'_, 'tcx> {
} }
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }

View file

@ -133,8 +133,8 @@ impl<'tcx> Visitor<'tcx> for BindingUsageFinder<'_, 'tcx> {
ControlFlow::Continue(()) ControlFlow::Continue(())
} }
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
} }

View file

@ -154,8 +154,8 @@ pub fn for_each_expr<'tcx, B, C: Continue>(
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
type Result = ControlFlow<B>; type Result = ControlFlow<B>;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx.hir() self.tcx
} }
fn visit_expr(&mut self, e: &'tcx Expr<'tcx>) -> Self::Result { fn visit_expr(&mut self, e: &'tcx Expr<'tcx>) -> Self::Result {
@ -412,8 +412,8 @@ pub fn is_expr_unsafe<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> bool {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
type Result = ControlFlow<()>; type Result = ControlFlow<()>;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
fn visit_expr(&mut self, e: &'tcx Expr<'_>) -> Self::Result { fn visit_expr(&mut self, e: &'tcx Expr<'_>) -> Self::Result {
match e.kind { match e.kind {
@ -477,8 +477,8 @@ pub fn contains_unsafe_block<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>)
impl<'tcx> Visitor<'tcx> for V<'_, 'tcx> { impl<'tcx> Visitor<'tcx> for V<'_, 'tcx> {
type Result = ControlFlow<()>; type Result = ControlFlow<()>;
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
fn visit_block(&mut self, b: &'tcx Block<'_>) -> Self::Result { fn visit_block(&mut self, b: &'tcx Block<'_>) -> Self::Result {
@ -544,8 +544,8 @@ pub fn for_each_local_use_after_expr<'tcx, B>(
} }
impl<'tcx, F: FnMut(&'tcx Expr<'tcx>) -> ControlFlow<B>, B> Visitor<'tcx> for V<'_, 'tcx, F, B> { impl<'tcx, F: FnMut(&'tcx Expr<'tcx>) -> ControlFlow<B>, B> Visitor<'tcx> for V<'_, 'tcx, F, B> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
fn visit_expr(&mut self, e: &'tcx Expr<'tcx>) { fn visit_expr(&mut self, e: &'tcx Expr<'tcx>) {
@ -729,8 +729,8 @@ pub fn for_each_local_assignment<'tcx, B>(
} }
impl<'tcx, F: FnMut(&'tcx Expr<'tcx>) -> ControlFlow<B>, B> Visitor<'tcx> for V<'_, 'tcx, F, B> { impl<'tcx, F: FnMut(&'tcx Expr<'tcx>) -> ControlFlow<B>, B> Visitor<'tcx> for V<'_, 'tcx, F, B> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = nested_filter::OnlyBodies;
fn nested_visit_map(&mut self) -> Self::Map { fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.cx.tcx.hir() self.cx.tcx
} }
fn visit_expr(&mut self, e: &'tcx Expr<'tcx>) { fn visit_expr(&mut self, e: &'tcx Expr<'tcx>) {