@@ -52,15 +52,6 @@ By default, if rustc encounters an Internal Compiler Error (ICE) it will dump th
52
52
ICE file within the current working directory named ` rustc-ice-<timestamp>-<pid>.txt ` . If this is
53
53
not desirable, you can prevent the ICE file from being created with ` RUSTC_ICE=0 ` .
54
54
55
- ## ` -Z ` flags
56
-
57
- The compiler has a bunch of ` -Z ` flags. These are unstable flags that are only
58
- enabled on nightly. Many of them are useful for debugging. To get a full listing
59
- of ` -Z ` flags, use ` -Z help ` .
60
-
61
- One useful flag is ` -Z verbose-internals ` , which generally enables printing more
62
- info that could be useful for debugging.
63
-
64
55
## Getting a backtrace
65
56
[ getting-a-backtrace ] : #getting-a-backtrace
66
57
@@ -109,7 +100,18 @@ stack backtrace:
109
100
at /home/user/rust/compiler/rustc_driver/src/lib.rs:253
110
101
```
111
102
112
- ## Getting a backtrace for errors
103
+ ## ` -Z ` flags
104
+
105
+ The compiler has a bunch of ` -Z * ` flags. These are unstable flags that are only
106
+ enabled on nightly. Many of them are useful for debugging. To get a full listing
107
+ of ` -Z ` flags, use ` -Z help ` .
108
+
109
+ One useful flag is ` -Z verbose-internals ` , which generally enables printing more
110
+ info that could be useful for debugging.
111
+
112
+ Right below you can find elaborate explainers on a selected few.
113
+
114
+ ### Getting a backtrace for errors
113
115
[ getting-a-backtrace-for-errors ] : #getting-a-backtrace-for-errors
114
116
115
117
If you want to get a backtrace to the point where the compiler emits an
@@ -186,14 +188,14 @@ stack backtrace:
186
188
187
189
Cool, now I have a backtrace for the error!
188
190
189
- ## Debugging delayed bugs
191
+ ### Debugging delayed bugs
190
192
191
193
The ` -Z eagerly-emit-delayed-bugs ` option makes it easy to debug delayed bugs.
192
194
It turns them into normal errors, i.e. makes them visible. This can be used in
193
195
combination with ` -Z treat-err-as-bug ` to stop at a particular delayed bug and
194
196
get a backtrace.
195
197
196
- ## Getting the error creation location
198
+ ### Getting the error creation location
197
199
198
200
` -Z track-diagnostics ` can help figure out where errors are emitted. It uses ` #[track_caller] `
199
201
for this and prints its location alongside the error:
@@ -235,21 +237,6 @@ The compiler uses the [`tracing`] crate for logging.
235
237
236
238
For details see [ the guide section on tracing] ( ./tracing.md )
237
239
238
- ## Formatting Graphviz output (.dot files)
239
- [ formatting-graphviz-output ] : #formatting-graphviz-output
240
-
241
- Some compiler options for debugging specific features yield graphviz graphs -
242
- e.g. the ` #[rustc_mir(borrowck_graphviz_postflow="suffix.dot")] ` attribute
243
- dumps various borrow-checker dataflow graphs.
244
-
245
- These all produce ` .dot ` files. To view these files, install graphviz (e.g.
246
- ` apt-get install graphviz ` ) and then run the following commands:
247
-
248
- ``` bash
249
- $ dot -T pdf maybe_init_suffix.dot > maybe_init_suffix.pdf
250
- $ firefox maybe_init_suffix.pdf # Or your favorite pdf viewer
251
- ```
252
-
253
240
## Narrowing (Bisecting) Regressions
254
241
255
242
The [ cargo-bisect-rustc] [ bisect ] tool can be used as a quick and easy way to
@@ -273,10 +260,37 @@ without doing the build yourself.
273
260
274
261
[ rtim ] : https://github.com/kennytm/rustup-toolchain-install-master
275
262
276
- ## Debugging type layouts
263
+ ## ` #[rustc_*] ` TEST attributes
264
+
265
+ The compiler defines a whole lot of internal (perma-unstable) attributes some of which are useful
266
+ for debugging by dumping extra compiler-internal information. These are prefixed with ` rustc_ ` and
267
+ are gated behind the internal feature ` rustc_attrs ` (enabled via e.g. ` #![feature(rustc_attrs)] ` ).
268
+
269
+ For a complete and up to date list, see [ ` builtin_attrs ` ] . More specifically, the ones marked ` TEST ` .
270
+
271
+ Right below you can find elaborate explainers on a selected few.
272
+
273
+ [ `builtin_attrs` ] : https://github.com/rust-lang/rust/blob/master/compiler/rustc_feature/src/builtin_attrs.rs
274
+
275
+ ### Formatting Graphviz output (.dot files)
276
+ [ formatting-graphviz-output ] : #formatting-graphviz-output
277
+
278
+ Some compiler options for debugging specific features yield graphviz graphs -
279
+ e.g. the ` #[rustc_mir(borrowck_graphviz_postflow="suffix.dot")] ` attribute
280
+ dumps various borrow-checker dataflow graphs.
281
+
282
+ These all produce ` .dot ` files. To view these files, install graphviz (e.g.
283
+ ` apt-get install graphviz ` ) and then run the following commands:
284
+
285
+ ``` bash
286
+ $ dot -T pdf maybe_init_suffix.dot > maybe_init_suffix.pdf
287
+ $ firefox maybe_init_suffix.pdf # Or your favorite pdf viewer
288
+ ```
289
+
290
+ ### Debugging type layouts
277
291
278
- The (permanently) unstable ` #[rustc_layout] ` attribute can be used to dump
279
- the [ ` Layout ` ] of the type it is attached to. For example:
292
+ The internal attribute ` #[rustc_layout] ` can be used to dump the [ ` Layout ` ] of
293
+ the type it is attached to. For example:
280
294
281
295
``` rust
282
296
#![feature(rustc_attrs)]
0 commit comments