]> git.lizzy.rs Git - rust.git/commitdiff
Docs: Add trace_macros! to unstable book
authorDanilo Bargen <mail@dbrgn.ch>
Sat, 30 Sep 2017 09:50:32 +0000 (11:50 +0200)
committerDanilo Bargen <mail@dbrgn.ch>
Sat, 30 Sep 2017 13:27:42 +0000 (15:27 +0200)
src/doc/unstable-book/src/language-features/trace-macros.md [new file with mode: 0644]

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 (file)
index 0000000..41aa286
--- /dev/null
@@ -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
+```