Skip to content

Commit 3c10c95

Browse files
authored
Merge pull request #511 from alercah/macro-names
Expand docs on Macros By Example.
2 parents e244040 + f628b29 commit 3c10c95

7 files changed

+834
-131
lines changed

src/SUMMARY.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@
115115

116116
- [The Rust runtime](runtime.md)
117117

118-
[Appendix: Influences](influences.md)
119-
120-
[Appendix: As-yet-undocumented Features](undocumented.md)
121-
122-
[Appendix: Glossary](glossary.md)
118+
- [Appendices](appendices.md)
119+
- [Macro Follow-Set Ambiguity Formal Specification](macro-ambiguity.md)
120+
- [Influences](influences.md)
121+
- [As-Yet-Undocumented Features](undocumented.md)
122+
- [Glossary](glossary.md)

src/appendices.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Appendices

src/attributes.md

+5-8
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,10 @@ which can be used to control type layout.
175175

176176
## Macro-related attributes
177177

178-
- `macro_use` on a `mod` — macros defined in this module will be visible in the
179-
module's parent, after this module has been included.
178+
- [`macro_use`] — Expands macro visibility, or imports macros from other
179+
crates.
180180

181-
- `macro_use` on an `extern crate` — load macros from this crate. An optional
182-
list of names `#[macro_use(foo, bar)]` restricts the import to just those
183-
macros named. The `extern crate` must appear at the crate root, not inside
184-
`mod`, which ensures proper function of the `$crate` macro variable.
185-
186-
- `macro_export` - export a `macro_rules` macro for cross-crate usage.
181+
- [`macro_export`] — Exports a `macro_rules` macro for cross-crate usage.
187182

188183
- `no_link` on an `extern crate` — even if we load this crate for macros, don't
189184
link it into the output.
@@ -634,3 +629,5 @@ pub fn f() {}
634629
[`meta` macro fragment specifier]: macros-by-example.html
635630
[`used`]: abi.html#the-used-attribute
636631
[`panic_handler`]: runtime.html#the-panic_handler-attribute
632+
[`macro_use`]: macros-by-example.html#the-macro_use-attribute
633+
[`macro_export`]: macros-by-example.html#path-based-scope

src/items/extern-crates.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ into the macro-use prelude.
9898
9999
[IDENTIFIER]: identifiers.html
100100
[RFC 940]: https://github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md
101-
[`#[macro_use]` attribute]: attributes.html#macro-related-attributes
101+
[`#[macro_use]` attribute]: macros-by-example.html#the-macro_use-attribute
102102
[`alloc`]: https://doc.rust-lang.org/alloc/
103103
[`crate::`]: paths.html#crate
104104
[`no_implicit_prelude`]: items/modules.html#prelude-items

src/items/modules.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ mod thread {
123123
## Prelude Items
124124

125125
Modules implicitly have some names in scope. These name are to built-in types,
126-
macros imported with `#[macro_use]` on an extern crate, and by the crate's
126+
macros imported with [`#[macro_use]`] on an extern crate, and by the crate's
127127
[prelude]. These names are all made of a single identifier. These names are not
128128
part of the module, so for example, any name `name`, `self::name` is not a
129129
valid path. The names added by the [prelude] can be removed by placing the
@@ -142,6 +142,7 @@ The built-in attributes that have meaning on a function are [`cfg`],
142142
[_InnerAttribute_]: attributes.html
143143
[_Item_]: items.html
144144
[_OuterAttribute_]: attributes.html
145+
[`#[macro_use]`]: macros-by-example.html#the-macro_use-attribute
145146
[`cfg`]: conditional-compilation.html
146147
[`deprecated`]: attributes.html#deprecation
147148
[`doc`]: attributes.html#documentation

0 commit comments

Comments
 (0)