Clean up trivial traversal/lift impl generator macro calls.

We have four macros for generating trivial traversal (fold/visit) and
lift impls.
- `rustc_ir::TrivialTypeTraversalImpls`
- `rustc_middle::TrivialTypeTraversalImpls`
- `rustc_middle::TrivialLiftImpls`
- `rustc_middle::TrivialTypeTraversalAndLiftImpls`

The first two are very similar. The last one just combines the second
and third one.

The macros themselves are ok, but their use is a mess. This commit does
the following.
- Removes types that no longer need a lift and/or traversal impl from
  the macro calls.
- Consolidates the macro calls into the smallest number of calls
  possible, with each one mentioning as many types as possible.
- Orders the types within those macro calls alphabetically, and makes
  the module qualification more consistent.
- Eliminates `rustc_middle::mir::type_foldable`, because the macro calls
  were merged and the manual `TypeFoldable` impls are better placed in
  `structural_impls.rs`, alongside all the other ones.

This makes the code more concise. Moving forward, it also makes it more
obvious where new types should be added.
This commit is contained in:
Nicholas Nethercote 2025-02-05 12:02:04 +11:00
parent e5f11af042
commit d28678e621
11 changed files with 100 additions and 151 deletions

View file

@ -34,7 +34,6 @@ use self::visit::TyContext;
use crate::mir::interpret::{AllocRange, Scalar};
use crate::mir::visit::MirVisitable;
use crate::ty::codec::{TyDecoder, TyEncoder};
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable};
use crate::ty::print::{FmtPrinter, Printer, pretty_print_const, with_no_trimmed_paths};
use crate::ty::visit::TypeVisitableExt;
use crate::ty::{
@ -59,7 +58,6 @@ pub mod tcx;
mod terminator;
pub mod traversal;
mod type_foldable;
pub mod visit;
pub use consts::*;
@ -927,8 +925,6 @@ pub enum BindingForm<'tcx> {
RefForGuard,
}
TrivialTypeTraversalImpls! { BindingForm<'tcx> }
mod binding_form_impl {
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_query_system::ich::StableHashingContext;