about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2015-11-17 21:44:39 -0500
committerNiko Matsakis <niko@alum.mit.edu>2015-11-18 19:23:29 -0500
commitdb97c93c9982f106c6eae1f7754a332f094b5647 (patch)
tree2f272da8fbe4a4998c29f85809d0cc49d52ede58
parent1e941f8e978bf868ff5fee21cf54afb3a0644eb9 (diff)
downloadrust-db97c93c9982f106c6eae1f7754a332f094b5647.tar.gz
rust-db97c93c9982f106c6eae1f7754a332f094b5647.zip
Add comment explaining why it is called `intravisit`
-rw-r--r--src/librustc_front/intravisit.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/librustc_front/intravisit.rs b/src/librustc_front/intravisit.rs
index 9c923ea32ef..3a43feb8ba7 100644
--- a/src/librustc_front/intravisit.rs
+++ b/src/librustc_front/intravisit.rs
@@ -13,15 +13,17 @@
 //! call `visit::walk_*` to apply the default traversal algorithm, or prevent
 //! deeper traversal by doing nothing.
 //!
-//! Note: it is an important invariant that the default visitor walks the body
-//! of a function in "execution order" (more concretely, reverse post-order
-//! with respect to the CFG implied by the AST), meaning that if AST node A may
-//! execute before AST node B, then A is visited first.  The borrow checker in
-//! particular relies on this property.
+//! When visiting the HIR, the contents of nested items are NOT visited
+//! by default. This is different from the AST visitor, which does a deep walk.
+//! Hence this module is called `intravisit`; see the method `visit_nested_item`
+//! for more details.
 //!
-//! Note: walking an AST before macro expansion is probably a bad idea. For
-//! instance, a walker looking for item names in a module will miss all of
-//! those that are created by the expansion of a macro.
+//! Note: it is an important invariant that the default visitor walks
+//! the body of a function in "execution order" (more concretely,
+//! reverse post-order with respect to the CFG implied by the AST),
+//! meaning that if AST node A may execute before AST node B, then A
+//! is visited first.  The borrow checker in particular relies on this
+//! property.
 
 use syntax::abi::Abi;
 use syntax::ast::{Ident, NodeId, CRATE_NODE_ID, Name, Attribute};
@@ -45,8 +47,10 @@ pub enum FnKind<'a> {
 /// the substructure of the input via the corresponding `walk` method;
 /// e.g. the `visit_mod` method by default calls `visit::walk_mod`.
 ///
-/// Note that this visitor does NOT visit nested items by default. If
-/// you simply want to visit all items in the crate in some order, you
+/// Note that this visitor does NOT visit nested items by default
+/// (this is why the module is called `intravisit`, to distinguish it
+/// from the AST's `visit` module, which acts differently). If you
+/// simply want to visit all items in the crate in some order, you
 /// should call `Crate::visit_all_items`. Otherwise, see the comment
 /// on `visit_nested_item` for details on how to visit nested items.
 ///