rustc_type_ir/
macros.rs

1/// Used for types that are `Copy` and which **do not care arena
2/// allocated data** (i.e., don't need to be folded).
3#[macro_export]
4macro_rules! TrivialTypeTraversalImpls {
5    ($($ty:ty,)+) => {
6        $(
7            impl<I: $crate::Interner> $crate::TypeFoldable<I> for $ty {
8                fn try_fold_with<F: $crate::FallibleTypeFolder<I>>(
9                    self,
10                    _: &mut F,
11                ) -> ::std::result::Result<Self, F::Error> {
12                    Ok(self)
13                }
14
15                #[inline]
16                fn fold_with<F: $crate::TypeFolder<I>>(
17                    self,
18                    _: &mut F,
19                ) -> Self {
20                    self
21                }
22            }
23
24            impl<I: $crate::Interner> $crate::TypeVisitable<I> for $ty {
25                #[inline]
26                fn visit_with<F: $crate::TypeVisitor<I>>(
27                    &self,
28                    _: &mut F)
29                    -> F::Result
30                {
31                    <F::Result as $crate::VisitorResult>::output()
32                }
33            }
34        )+
35    };
36}
37
38///////////////////////////////////////////////////////////////////////////
39// Atomic structs
40//
41// For things that don't carry any arena-allocated data (and are
42// copy...), just add them to this list.
43
44TrivialTypeTraversalImpls! {
45    (),
46    bool,
47    usize,
48    u16,
49    u32,
50    u64,
51    // tidy-alphabetical-start
52    crate::AliasRelationDirection,
53    crate::BoundConstness,
54    crate::DebruijnIndex,
55    crate::PredicatePolarity,
56    crate::solve::BuiltinImplSource,
57    crate::solve::Certainty,
58    crate::solve::GoalSource,
59    crate::UniverseIndex,
60    crate::Variance,
61    rustc_ast_ir::Mutability,
62    // tidy-alphabetical-end
63}