Skip to content

Commit f26d35b

Browse files
author
Keegan McAllister
committed
---
yaml --- r: 172269 b: refs/heads/master c: a96a8b2 h: refs/heads/master i: 172267: 5bb3f23 v: v3
1 parent 4ba85c9 commit f26d35b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 128e7ff53b9e7330ca78f961030ac307f5a6fc47
2+
refs/heads/master: a96a8b2b2526aaa631183f71aef9acf390b61f48
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 5b3cd3900ceda838f5798c30ab96ceb41f962534
55
refs/heads/try: 705b92bdfe33d0d6febdf945340262514e1b3b5c

trunk/src/doc/trpl/macros.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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

446447
Definition and expansion of macros both happen in a single depth-first,
447448
lexical-order traversal of a crate's source. So a macro defined at module scope
448449
is visible to any subsequent code in the same module, which includes the body
449450
of 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+
451455
If a module has the `macro_use` attribute, its macros are also visible in its
452456
parent module after the child's `mod` item. If the parent also has `macro_use`
453457
then the macros will be visible in the grandparent after the parent's `mod`

0 commit comments

Comments
 (0)