rust/compiler/rustc_resolve/src
bors c2ec7532ee 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.
2025-06-22 14:03:44 +00:00
..
late Fix PathSource lifetimes. 2025-06-16 10:33:00 +10:00
rustdoc source_span_for_markdown_range: fix utf8 violation 2025-05-31 14:51:16 -05:00
build_reduced_graph.rs resolve: Tweak private_macro_use lint to be compatible with upcoming macro prelude changes 2025-06-03 00:09:54 +03:00
check_unused.rs deduplicate more walk_* methods in AST visit 2025-06-06 04:59:26 +00:00
def_collector.rs remove equivalent new method on context 2025-06-20 07:50:11 +02:00
diagnostics.rs Detect when attribute is provided by missing derive macro 2025-06-12 21:28:49 +00:00
effective_visibilities.rs Reorder ast::ItemKind::{Struct,Enum,Union} fields. 2025-05-28 15:48:45 +10:00
errors.rs resolve: Support imports of associated types and glob imports from traits 2025-05-02 15:59:38 +03:00
ident.rs Detect when attribute is provided by missing derive macro 2025-06-12 21:28:49 +00:00
imports.rs resolve: Tweak private_macro_use lint to be compatible with upcoming macro prelude changes 2025-06-03 00:09:54 +03:00
late.rs Auto merge of #142706 - fee1-dead-contrib:push-zsznlqyrzsqo, r=oli-obk 2025-06-22 14:03:44 +00:00
lib.rs Auto merge of #134841 - estebank:serde-attr-4, r=wesleywiser 2025-06-13 22:59:24 +00:00
macros.rs Auto merge of #134841 - estebank:serde-attr-4, r=wesleywiser 2025-06-13 22:59:24 +00:00
rustdoc.rs Add AttributeExt::doc_resolution_scope 2025-06-21 11:09:12 -07:00