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