diff options
| author | bors <bors@rust-lang.org> | 2017-09-30 20:46:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-09-30 20:46:57 +0000 |
| commit | afe9320785efa17ea1adbdab299a6aaf2c575e87 (patch) | |
| tree | 205a883aad81dd979d24babc27afc32e18ad01dc | |
| parent | c6884b12d9298f1e0af919cb9458a0d80acb3b0a (diff) | |
| parent | eb59952fbdb217101834325fa7e08074b735a3e0 (diff) | |
| download | rust-afe9320785efa17ea1adbdab299a6aaf2c575e87.tar.gz rust-afe9320785efa17ea1adbdab299a6aaf2c575e87.zip | |
Auto merge of #44944 - dbrgn:trace-macros-docs, r=QuietMisdreavus
Docs: Add trace_macros! to unstable book As TIL'd at Rustfest :) Note: This is unfortunately untested, since I'm on my laptop battery, and compiling LLVM would probably eat at least 50% of it on my dual core CPU. (Is there a way to build docs without compiling LLVM?)
| -rw-r--r-- | src/doc/unstable-book/src/language-features/trace-macros.md | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/trace-macros.md b/src/doc/unstable-book/src/language-features/trace-macros.md new file mode 100644 index 00000000000..41aa286e69b --- /dev/null +++ b/src/doc/unstable-book/src/language-features/trace-macros.md @@ -0,0 +1,39 @@ +# `trace_macros` + +The tracking issue for this feature is [#29598]. + +[#29598]: https://github.com/rust-lang/rust/issues/29598 + +------------------------ + +With `trace_macros` you can trace the expansion of macros in your code. + +## Examples + +```rust +#![feature(trace_macros)] + +fn main() { + trace_macros!(true); + println!("Hello, Rust!"); + trace_macros!(false); +} +``` + +The `cargo build` output: + +```txt +note: trace_macro + --> src/main.rs:5:5 + | +5 | println!("Hello, Rust!"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: expanding `println! { "Hello, Rust!" }` + = note: to `print ! ( concat ! ( "Hello, Rust!" , "\n" ) )` + = note: expanding `print! { concat ! ( "Hello, Rust!" , "\n" ) }` + = note: to `$crate :: io :: _print ( format_args ! ( concat ! ( "Hello, Rust!" , "\n" ) ) + )` + + Finished dev [unoptimized + debuginfo] target(s) in 0.60 secs +``` |
