Auto merge of #90986 - camsteffen:nested-filter, r=cjgillot
Replace `NestedVisitorMap` with generic `NestedFilter` This is an attempt to make the `intravisit::Visitor` API simpler and "more const" with regard to nested visiting. With this change, `intravisit::Visitor` does not visit nested things by default, unless you specify `type NestedFilter = nested_filter::OnlyBodies` (or `All`). `nested_visit_map` returns `Self::Map` instead of `NestedVisitorMap<Self::Map>`. It panics by default (unreachable if `type NestedFilter` is omitted). One somewhat trixty thing here is that `nested_filter::{OnlyBodies, All}` live in `rustc_middle` so that they may have `type Map = map::Map` and so that `impl Visitor`s never need to specify `type Map` - it has a default of `Self::NestedFilter::Map`.
This commit is contained in:
commit
ee5d8d37ba
110 changed files with 388 additions and 947 deletions
|
@ -2184,12 +2184,6 @@ struct FindTypeParam {
|
|||
}
|
||||
|
||||
impl<'v> Visitor<'v> for FindTypeParam {
|
||||
type Map = rustc_hir::intravisit::ErasedMap<'v>;
|
||||
|
||||
fn nested_visit_map(&mut self) -> hir::intravisit::NestedVisitorMap<Self::Map> {
|
||||
hir::intravisit::NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_where_predicate(&mut self, _: &'v hir::WherePredicate<'v>) {
|
||||
// Skip where-clauses, to avoid suggesting indirection for type parameters found there.
|
||||
}
|
||||
|
|
|
@ -2519,12 +2519,6 @@ pub struct ReturnsVisitor<'v> {
|
|||
}
|
||||
|
||||
impl<'v> Visitor<'v> for ReturnsVisitor<'v> {
|
||||
type Map = hir::intravisit::ErasedMap<'v>;
|
||||
|
||||
fn nested_visit_map(&mut self) -> hir::intravisit::NestedVisitorMap<Self::Map> {
|
||||
hir::intravisit::NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, ex: &'v hir::Expr<'v>) {
|
||||
// Visit every expression to detect `return` paths, either through the function's tail
|
||||
// expression or `return` statements. We walk all nodes to find `return` statements, but
|
||||
|
@ -2581,12 +2575,6 @@ struct AwaitsVisitor {
|
|||
}
|
||||
|
||||
impl<'v> Visitor<'v> for AwaitsVisitor {
|
||||
type Map = hir::intravisit::ErasedMap<'v>;
|
||||
|
||||
fn nested_visit_map(&mut self) -> hir::intravisit::NestedVisitorMap<Self::Map> {
|
||||
hir::intravisit::NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, ex: &'v hir::Expr<'v>) {
|
||||
if let hir::ExprKind::Yield(_, hir::YieldSource::Await { expr: Some(id) }) = ex.kind {
|
||||
self.awaits.push(id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue