about summary refs log tree commit diff
path: root/compiler/rustc_ast/src
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2025-06-04 16:40:00 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2025-06-04 16:40:00 +1000
commited300d8ad881acc54f56a965e9c8f8a9e75a06d8 (patch)
tree6ec36b4daa07c50cc97b512bdf519e05c061a99e /compiler/rustc_ast/src
parenta124fb3cb7291d75872934f411d81fe298379ace (diff)
downloadrust-ed300d8ad881acc54f56a965e9c8f8a9e75a06d8.tar.gz
rust-ed300d8ad881acc54f56a965e9c8f8a9e75a06d8.zip
Improve some `Visitor` comments.
For AST/HIR/THIR visitors, explain the use of deconstruction.
Diffstat (limited to 'compiler/rustc_ast/src')
-rw-r--r--compiler/rustc_ast/src/visit.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs
index 908d9fd4bda..1f7c97380dc 100644
--- a/compiler/rustc_ast/src/visit.rs
+++ b/compiler/rustc_ast/src/visit.rs
@@ -121,6 +121,10 @@ pub enum LifetimeCtxt {
 /// explicitly, you need to override each method. (And you also need
 /// to monitor future changes to `Visitor` in case a new method with a
 /// new default implementation gets introduced.)
+///
+/// Every `walk_*` method uses deconstruction to access fields of structs and
+/// enums. This will result in a compile error if a field is added, which makes
+/// it more likely the appropriate visit call will be added for it.
 pub trait Visitor<'ast>: Sized {
     /// The result type of the `visit_*` methods. Can be either `()`,
     /// or `ControlFlow<T>`.