Skip to content

Commit afe9320

Browse files
committed
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?)
2 parents c6884b1 + eb59952 commit afe9320

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# `trace_macros`
2+
3+
The tracking issue for this feature is [#29598].
4+
5+
[#29598]: https://github.com/rust-lang/rust/issues/29598
6+
7+
------------------------
8+
9+
With `trace_macros` you can trace the expansion of macros in your code.
10+
11+
## Examples
12+
13+
```rust
14+
#![feature(trace_macros)]
15+
16+
fn main() {
17+
trace_macros!(true);
18+
println!("Hello, Rust!");
19+
trace_macros!(false);
20+
}
21+
```
22+
23+
The `cargo build` output:
24+
25+
```txt
26+
note: trace_macro
27+
--> src/main.rs:5:5
28+
|
29+
5 | println!("Hello, Rust!");
30+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
31+
|
32+
= note: expanding `println! { "Hello, Rust!" }`
33+
= note: to `print ! ( concat ! ( "Hello, Rust!" , "\n" ) )`
34+
= note: expanding `print! { concat ! ( "Hello, Rust!" , "\n" ) }`
35+
= note: to `$crate :: io :: _print ( format_args ! ( concat ! ( "Hello, Rust!" , "\n" ) )
36+
)`
37+
38+
Finished dev [unoptimized + debuginfo] target(s) in 0.60 secs
39+
```

0 commit comments

Comments
 (0)