Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand docs on Macros By Example. #511

Merged
merged 4 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@

- [The Rust runtime](runtime.md)

[Appendix: Influences](influences.md)

[Appendix: As-yet-undocumented Features](undocumented.md)

[Appendix: Glossary](glossary.md)
- [Appendices](appendices.md)
- [Macro Follow-Set Ambiguity Formal Specification](macro-ambiguity.md)
- [Influences](influences.md)
- [As-Yet-Undocumented Features](undocumented.md)
- [Glossary](glossary.md)
1 change: 1 addition & 0 deletions src/appendices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Appendices
13 changes: 5 additions & 8 deletions src/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,10 @@ which can be used to control type layout.

## Macro-related attributes

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

- `macro_use` on an `extern crate` — load macros from this crate. An optional
list of names `#[macro_use(foo, bar)]` restricts the import to just those
macros named. The `extern crate` must appear at the crate root, not inside
`mod`, which ensures proper function of the `$crate` macro variable.

- `macro_export` - export a `macro_rules` macro for cross-crate usage.
- [`macro_export`] — Exports a `macro_rules` macro for cross-crate usage.

- `no_link` on an `extern crate` — even if we load this crate for macros, don't
link it into the output.
Expand Down Expand Up @@ -634,3 +629,5 @@ pub fn f() {}
[`meta` macro fragment specifier]: macros-by-example.html
[`used`]: abi.html#the-used-attribute
[`panic_handler`]: runtime.html#the-panic_handler-attribute
[`macro_use`]: macros-by-example.html#the-macro_use-attribute
[`macro_export`]: macros-by-example.html#path-based-scope
2 changes: 1 addition & 1 deletion src/items/extern-crates.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ into the macro-use prelude.

[IDENTIFIER]: identifiers.html
[RFC 940]: https://github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md
[`#[macro_use]` attribute]: attributes.html#macro-related-attributes
[`#[macro_use]` attribute]: macros-by-example.html#the-macro_use-attribute
[`alloc`]: https://doc.rust-lang.org/alloc/
[`crate::`]: paths.html#crate
[`no_implicit_prelude`]: items/modules.html#prelude-items
Expand Down
3 changes: 2 additions & 1 deletion src/items/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ mod thread {
## Prelude Items

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