]> git.proxmox.com Git - rustc.git/blob - src/doc/unstable-book/src/language-features/trace-macros.md
New upstream version 1.22.1+dfsg1
[rustc.git] / src / doc / unstable-book / src / language-features / trace-macros.md
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 ```