Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2e56c02

Browse files
committedFeb 15, 2022
Address review comments.
1 parent c76f01c commit 2e56c02

File tree

1 file changed

+13
-2
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+13
-2
lines changed
 

Diff for: ‎compiler/rustc_middle/src/ty/fold.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@
3838
//! might provide custom handling only for some types of interest, or only
3939
//! for some variants of each type of interest, and then use default
4040
//! traversal for the remaining cases.
41+
//!
42+
//! For example, if you have `struct S(Ty, U)` where `S: TypeFoldable` and `U:
43+
//! TypeFoldable`, and an instance `S(ty, u)`, it would be visited like so:
44+
//! ```
45+
//! s.visit_with(visitor) calls
46+
//! - s.super_visit_with(visitor) calls
47+
//! - ty.visit_with(visitor) calls
48+
//! - visitor.visit_ty(ty) may call
49+
//! - ty.super_visit_with(visitor)
50+
//! - u.visit_with(visitor)
51+
//! ```
4152
use crate::mir;
4253
use crate::ty::{self, flags::FlagComputation, Binder, Ty, TyCtxt, TypeFlags};
4354
use rustc_hir::def_id::DefId;
@@ -96,7 +107,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
96107
/// For types of interest (such as `Ty`), this default is overridden with a
97108
/// method that calls a visitor method specifically for that type (such as
98109
/// `V::visit_ty`). This is where control transfers from `TypeFoldable` to
99-
/// `TypeFolder`.
110+
/// `TypeVisitor`.
100111
///
101112
/// For other types, this default is used.
102113
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
@@ -349,7 +360,7 @@ where
349360

350361
/// This trait is implemented for every visiting traversal. There is a visit
351362
/// method defined for every type of interest. Each such method has a default
352-
/// that does a non-custom visit.
363+
/// that recurses into the type's fields in a non-custom fashion.
353364
pub trait TypeVisitor<'tcx>: Sized {
354365
type BreakTy = !;
355366

0 commit comments

Comments
 (0)
Please sign in to comment.