Compare commits

...

12 Commits

Author SHA1 Message Date
AngelicosPhosphoros d4080766a6
Merge ae15da5783 into 51817951d0 2024-04-27 11:42:00 -07:00
Eric Huss 51817951d0
Merge pull request #1468 from petrochenkov/debmac
Add docs for `#[collapse_debuginfo]` attribute
2024-04-27 17:54:45 +00:00
Eric Huss 2d51a2aec4 Add an example of collapse_debuginfo 2024-04-27 10:53:08 -07:00
Eric Huss c495b9660f Link `collapse_debuginfo` in the index of built-in attributes. 2024-02-14 10:21:12 -08:00
Eric Huss 860fe4acc1 Use semantic line wrapping. 2024-02-14 10:18:40 -08:00
Eric Huss 4e9c91f0ec Place `rustc` behavior in a side note.
Generally the reference tries to stay focused on the language, and only
provide implementation notes as side-information.
2024-02-14 10:17:29 -08:00
Eric Huss 224b6c5306 Use em-dash separator 2024-02-14 10:16:40 -08:00
Eric Huss bb166095d1 Use standard template introducing an attribute. 2024-02-14 10:16:23 -08:00
Vadim Petrochenkov 0bf5d4e44c Add docs for `#[collapse_debuginfo]` attribute 2024-02-13 16:26:42 +03:00
AngelicosPhosphoros ae15da5783
Wording change
Co-authored-by: Eric Huss <eric@huss.org>
2024-01-06 17:34:29 +01:00
AngelicosPhosphoros 56b6225316
Add info about what is overflow
Co-authored-by: Eric Huss <eric@huss.org>
2023-06-16 00:29:48 +04:00
AngelicosPhosphoros 97ddb9dfa5 Add entry about `cfg!(overflow_checks)`
Related to https://github.com/rust-lang/rust/pull/111096
2023-05-02 19:33:43 +04:00
3 changed files with 37 additions and 0 deletions

View File

@ -275,6 +275,7 @@ The following is an index of all built-in attributes.
added in future.
- Debugger
- [`debugger_visualizer`] — Embeds a file that specifies debugger output for a type.
- [`collapse_debuginfo`] — Controls how macro invocations are encoded in debuginfo.
[Doc comments]: comments.md#doc-comments
[ECMA-334]: https://www.ecma-international.org/publications-and-standards/standards/ecma-334/
@ -293,6 +294,7 @@ The following is an index of all built-in attributes.
[`cfg_attr`]: conditional-compilation.md#the-cfg_attr-attribute
[`cfg`]: conditional-compilation.md#the-cfg-attribute
[`cold`]: attributes/codegen.md#the-cold-attribute
[`collapse_debuginfo`]: attributes/debugger.md#the-collapse_debuginfo-attribute
[`crate_name`]: crates-and-source-files.md#the-crate_name-attribute
[`crate_type`]: linkage.md
[`debugger_visualizer`]: attributes/debugger.md#the-debugger_visualizer-attribute

View File

@ -139,3 +139,32 @@ When the crate's debug executable is passed into GDB[^rust-gdb], `print bob` wil
[Natvis documentation]: https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects
[pretty printing documentation]: https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing.html
[_MetaListNameValueStr_]: ../attributes.md#meta-item-attribute-syntax
## The `collapse_debuginfo` attribute
The *`collapse_debuginfo` [attribute]* controls whether code locations from a macro definition are collapsed into a single location associated with the macro's call site,
when generating debuginfo for code calling this macro.
The attribute uses the [_MetaListIdents_] syntax to specify its inputs, and can only be applied to macro definitions.
Accepted options:
- `#[collapse_debuginfo(yes)]` — code locations in debuginfo are collapsed.
- `#[collapse_debuginfo(no)]` — code locations in debuginfo are not collapsed.
- `#[collapse_debuginfo(external)]` — code locations in debuginfo are collapsed only if the macro comes from a different crate.
The `external` behavior is the default for macros that don't have this attribute, unless they are built-in macros.
For built-in macros the default is `yes`.
> **Note**: `rustc` has a `-C collapse-macro-debuginfo` CLI option to override both the default collapsing behavior and `#[collapse_debuginfo]` attributes.
```rust
#[collapse_debuginfo(yes)]
macro_rules! example {
() => {
println!("hello!");
};
}
```
[attribute]: ../attributes.md
[_MetaListIdents_]: ../attributes.md#meta-item-attribute-syntax

View File

@ -238,6 +238,12 @@ This can be used to enable extra debugging code in development but not in
production. For example, it controls the behavior of the standard library's
[`debug_assert!`] macro.
### `overflow_checks`
Enabled when compiling with [overflow checks] enabled, e.g. in development builds.
[overflow checks]: expressions/operator-expr.md#overflow
### `proc_macro`
Set when the crate being compiled is being compiled with the `proc_macro`