File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -440,14 +440,18 @@ to print "I am never printed" and to run forever.
440440
441441# Scoping and macro import/export
442442
443- Macros occupy a single global namespace. The interaction with Rust's system of
444- modules and crates is somewhat complex.
443+ Macros are expanded at an early stage in compilation, before name resolution.
444+ One downside is that scoping works differently for macros, compared to other
445+ constructs in the language.
445446
446447Definition and expansion of macros both happen in a single depth-first,
447448lexical-order traversal of a crate's source. So a macro defined at module scope
448449is visible to any subsequent code in the same module, which includes the body
449450of any subsequent child ` mod ` items.
450451
452+ A macro defined within the body of a single ` fn ` , or anywhere else not at
453+ module scope, is visible only within that item.
454+
451455If a module has the ` macro_use ` attribute, its macros are also visible in its
452456parent module after the child's ` mod ` item. If the parent also has ` macro_use `
453457then the macros will be visible in the grandparent after the parent's ` mod `
You can’t perform that action at this time.
0 commit comments