Skip to content

Commit df98a74

Browse files
committed
Explain why TypeFoldable is a sub-trait of TypeVisitable.
1 parent 593373f commit df98a74

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

compiler/rustc_type_ir/src/fold.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ use crate::{visit::TypeVisitable, Interner};
5151
///
5252
/// To implement this conveniently, use the derive macro located in
5353
/// `rustc_macros`.
54+
///
55+
/// This trait is a sub-trait of `TypeVisitable`. This is because many
56+
/// `TypeFolder` instances use the methods in `TypeVisitableExt` while folding,
57+
/// which means in practice almost every foldable type needs to also be
58+
/// visitable. (However, there are some types that are visitable without being
59+
/// foldable.)
5460
pub trait TypeFoldable<I: Interner>: TypeVisitable<I> {
5561
/// The entry point for folding. To fold a value `t` with a folder `f`
5662
/// call: `t.try_fold_with(f)`.

0 commit comments

Comments
 (0)