rust/compiler/rustc_expand/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
..
mbe mbe: Refactor transcription 2025-06-19 16:28:52 +00:00
base.rs Remove an njn: comment accidentaly left behind. 2025-06-16 15:18:48 +10:00
build.rs Improve pretty-printing of braces. 2025-04-29 13:46:17 +10:00
config.rs Note the version and PR of removed features when using it 2025-06-09 17:10:58 +08:00
errors.rs Use a symbol for ExpansionConfig::crate_name. 2025-06-20 13:17:39 +10:00
expand.rs Auto merge of #142706 - fee1-dead-contrib:push-zsznlqyrzsqo, r=oli-obk 2025-06-22 14:03:44 +00:00
lib.rs Introduce -Zmacro-stats. 2025-06-12 21:17:17 +10:00
mbe.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
module.rs Reject macro calls inside of #![crate_name] 2025-02-15 16:47:30 +01:00
placeholders.rs completely deduplicate Visitor and MutVisitor 2025-06-19 17:50:44 +08:00
proc_macro.rs Do not get proc_macro from the sysroot in rustc 2025-05-27 15:49:28 +00:00
proc_macro_server.rs Do not get proc_macro from the sysroot in rustc 2025-05-27 15:49:28 +00:00
stats.rs Introduce -Zmacro-stats. 2025-06-12 21:17:17 +10:00