about summary refs log tree commit diff
path: root/compiler/rustc_ast/src
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-06-04 16:24:12 +0200
committerGitHub <noreply@github.com>2025-06-04 16:24:12 +0200
commita06160d9a8b0b695b871b444e10016de033fa5ed (patch)
tree7241f3c32c7c18c9931f6198c32cc509e4f5c987 /compiler/rustc_ast/src
parent820971581ac7e8b6fe66526e8f593a3c7be64a2e (diff)
parented300d8ad881acc54f56a965e9c8f8a9e75a06d8 (diff)
downloadrust-a06160d9a8b0b695b871b444e10016de033fa5ed.tar.gz
rust-a06160d9a8b0b695b871b444e10016de033fa5ed.zip
Rollup merge of #142007 - nnethercote:visitor-comments, r=chenyukang
Improve some `Visitor` comments.

For AST/HIR/THIR visitors, explain the use of deconstruction.

r? ``@BoxyUwU``
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>`.