summary refs log tree commit diff
path: root/compiler/rustc_parse/src/validate_attr.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-06-22 14:03:44 +0000
committerbors <bors@rust-lang.org>2025-06-22 14:03:44 +0000
commitc2ec7532eed172e79800d28f087727c4b048badd (patch)
tree597044dc3a613abc3c1e4fa159948832ae2e3c3b /compiler/rustc_parse/src/validate_attr.rs
parenta30f1783fe136d92545423dd30b12eb619973cdb (diff)
parent3da58e673a723378942fc1828e45956025c97569 (diff)
downloadrust-c2ec7532eed172e79800d28f087727c4b048badd.tar.gz
rust-c2ec7532eed172e79800d28f087727c4b048badd.zip
Auto merge of #142706 - fee1-dead-contrib:push-zsznlqyrzsqo, r=oli-obk
completely deduplicate `Visitor` and `MutVisitor`

r? oli-obk

This closes rust-lang/rust#127615.

### Discussion

> * Give every `MutVisitor::visit_*` method a corresponding `flat_map_*` method.

Not every AST node exists in a location where they can be mapped to multiple instances of themselves. Not every AST node exists in a location where they can be removed from existence (e.g. `filter_map_expr`). I don't think this is doable.

> * Give every `MutVisitor::visit_*` method a corresponding `Visitor` method and vice versa

The only three remaining method-level asymmetries after this PR are `visit_stmt` and `visit_nested_use_tree` (only on `Visitor`) and `visit_span` (only on `MutVisitor`).

`visit_stmt` doesn't seem applicable to `MutVisitor` because `walk_flat_map_stmt_kind` will ask `flat_map_item` / `filter_map_expr` to potentially turn a single `Stmt` to multiple based on what a visitor wants. So only using `flat_map_stmt` seems appropriate.

`visit_nested_use_tree` is used for `rustc_resolve` to track stuff. Not useful for `MutVisitor` for now.

`visit_span` is currently not used for `MutVisitor` already, it was just kept in case we want to revive rust-lang/rust#127241. cc `@cjgillot` maybe we could remove for now and re-insert later if we find a use-case? It does involve some extra effort to maintain.

* Remaining FIXMEs

`visit_lifetime` has an extra param for `Visitor` that's not in `MutVisitor`. This is again something only used by `rustc_resolve`. I think we can keep that symmetry for now.
Diffstat (limited to 'compiler/rustc_parse/src/validate_attr.rs')
0 files changed, 0 insertions, 0 deletions