about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKeegan McAllister <kmcallister@mozilla.com>2015-01-08 11:56:10 -0800
committerKeegan McAllister <kmcallister@mozilla.com>2015-01-09 11:06:17 -0800
commita96a8b2b2526aaa631183f71aef9acf390b61f48 (patch)
tree0abe7f693404f8a48543ba0b4a09b3f9e0705672
parent128e7ff53b9e7330ca78f961030ac307f5a6fc47 (diff)
downloadrust-a96a8b2b2526aaa631183f71aef9acf390b61f48.tar.gz
rust-a96a8b2b2526aaa631183f71aef9acf390b61f48.zip
Update macro scope intro
-rw-r--r--src/doc/trpl/macros.md8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/doc/trpl/macros.md b/src/doc/trpl/macros.md
index c694806b4ba..9b9af2c65ca 100644
--- a/src/doc/trpl/macros.md
+++ b/src/doc/trpl/macros.md
@@ -440,14 +440,18 @@ to print "I am never printed" and to run forever.
 
 # Scoping and macro import/export
 
-Macros occupy a single global namespace. The interaction with Rust's system of
-modules and crates is somewhat complex.
+Macros are expanded at an early stage in compilation, before name resolution.
+One downside is that scoping works differently for macros, compared to other
+constructs in the language.
 
 Definition and expansion of macros both happen in a single depth-first,
 lexical-order traversal of a crate's source. So a macro defined at module scope
 is visible to any subsequent code in the same module, which includes the body
 of any subsequent child `mod` items.
 
+A macro defined within the body of a single `fn`, or anywhere else not at
+module scope, is visible only within that item.
+
 If a module has the `macro_use` attribute, its macros are also visible in its
 parent module after the child's `mod` item. If the parent also has `macro_use`
 then the macros will be visible in the grandparent after the parent's `mod`