@@ -294,28 +294,44 @@ above and reference it via the `#![debugger_visualizer]` attribute as follows:
294
294
# Reference-level explanation
295
295
[ reference-level-explanation ] : #reference-level-explanation
296
296
297
- In rustc, a new built-in crate-level attribute ` #! [debugger_visualizer] ` will be
298
- added which instructs the compiler to take the debugger visualizer specified by the
299
- attribute and add it to the current binary being built. The file path specified must
300
- be relative to the location of the attribute and is resolved in a manner that is
301
- identical to how paths are resolved in the ` include_str! ` macro.
302
-
303
- Since the ` #![debugger_visualizer] ` is a crate- level attribute, any usage of this
304
- attribute in a different context (i.e. targeting types, modules, etc) will cause a
305
- compiler error .
306
-
307
- For example, the ` #![debugger_visualizer] ` attribute may be used in the following :
297
+ In rustc, a new built-in attribute ` #[debugger_visualizer] ` will be added which
298
+ instructs the compiler to take the specified file path for a debugger visualizer
299
+ and add it to the current binary being built. The file path specified must be
300
+ relative to the location of the attribute and is resolved in a manner that is
301
+ identical to how paths are resolved in the ` include_str! ` macro. This attribute
302
+ will directly target modules which means the syntax ` #![debugger_visualizer] ` is
303
+ also valid when placed at the module level. This would allow for this attribute to
304
+ be used as a crate-level attribute as well which is different than a typical module item
305
+ when placed at the top-level crate file, ` lib.rs ` or ` main.rs ` .
306
+
307
+ For example, the following uses of the attribute are valid :
308
308
309
309
Where ` main.rs ` contains:
310
310
311
311
``` rust
312
312
#![debugger_visualizer(natvis_file = " ../main.natvis" )]
313
+
314
+ #[debugger_visualizer(natvis_file = " ../foo.natvis" )]
315
+ mod foo ;
316
+ ```
317
+
318
+ and ` bar.rs ` contains:
319
+
320
+ ``` rust
321
+ #![debugger_visualizer(natvis_file = " ../bar.natvis" )]
313
322
```
314
323
315
- The attribute must be placed at the top of ` main.rs ` where other crate-level
316
- attributes are placed.
324
+ In the first case, the attribute is applied to the crate as a crate-level attribute
325
+ using the inner attribute syntax on the top-level crate source file. It is also
326
+ added to the module foo using the outer attribute syntax. In the second case,
327
+ the attribute is applied to the module bar using the inner attribute syntax which
328
+ also is valid since it is still targeting a module.
329
+
330
+ The only valid targets for this attribute are modules or as a crate-level attribute.
331
+ Using this attribute on any other target, for instance a type or a function, will
332
+ cause rustc to raise a compiler error that will need to be resolved.
317
333
318
- The ` #! [debugger_visualizer] ` attribute will reserve multiple keys to be able to
334
+ The ` #[debugger_visualizer] ` attribute will reserve multiple keys to be able to
319
335
specify which type of visualizer is being applied. The following keys will be
320
336
reserved as part of this RFC:
321
337
@@ -600,8 +616,9 @@ struct FancyRect {
600
616
}
601
617
```
602
618
603
- Currently the ` #![debugger_visualizer] ` attribute is only allowed to be used as a
604
- crate-level attribute. This can be updated to allow targeting types as well if the
619
+ Currently the ` #[debugger_visualizer] ` attribute is only allowed to target modules
620
+ which includes being used as crate-level attribute when targeting the top-level
621
+ ` *.rs ` source file. This can be updated to allow targeting types as well if the
605
622
same attribute was to be re-used to support this.
606
623
607
624
## Inline Natvis XML fragments via a macro
0 commit comments