mirror of https://github.com/rust-lang/reference
Compare commits
10 Commits
5e752740dd
...
0842490ab7
Author | SHA1 | Date |
---|---|---|
multisn8 | 0842490ab7 | |
Eric Huss | 51817951d0 | |
Eric Huss | 2d51a2aec4 | |
MultisampledNight | 416f4c9505 | |
Eric Huss | c495b9660f | |
Eric Huss | 860fe4acc1 | |
Eric Huss | 4e9c91f0ec | |
Eric Huss | 224b6c5306 | |
Eric Huss | bb166095d1 | |
Vadim Petrochenkov | 0bf5d4e44c |
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -397,6 +397,9 @@ match tuple {
|
|||
> | _RangeToInclusivePattern_\
|
||||
> | _ObsoleteRangePattern_
|
||||
>
|
||||
> _RangeExclusivePattern_ :\
|
||||
> _RangePatternBound_ `..` _RangePatternBound_
|
||||
>
|
||||
> _RangeInclusivePattern_ :\
|
||||
> _RangePatternBound_ `..=` _RangePatternBound_
|
||||
>
|
||||
|
@ -422,10 +425,11 @@ A bound on the left of the sigil is a *lower bound*.
|
|||
A bound on the right is an *upper bound*.
|
||||
|
||||
A range pattern with both a lower and upper bound will match all values between and including both of its bounds.
|
||||
It is written as its lower bound, followed by `..=`, followed by its upper bound.
|
||||
It is written as its lower bound, followed by `..` for end-exclusive or `..=` for end-inclusive, followed by its upper bound.
|
||||
The type of the range pattern is the type unification of its upper and lower bounds.
|
||||
|
||||
For example, a pattern `'m'..='p'` will match only the values `'m'`, `'n'`, `'o'`, and `'p'`.
|
||||
Similarly, `'m'..'p'` will match only `'m'`, `'n'` and `'o'`, specifically **not** including `'p'`.
|
||||
|
||||
The lower bound cannot be greater than the upper bound.
|
||||
That is, in `a..=b`, a ≤ b must be the case.
|
||||
|
@ -467,7 +471,7 @@ let valid_variable = match c {
|
|||
|
||||
# let ph = 10;
|
||||
println!("{}", match ph {
|
||||
0..=6 => "acid",
|
||||
0..7 => "acid",
|
||||
7 => "neutral",
|
||||
8..=14 => "base",
|
||||
_ => unreachable!(),
|
||||
|
@ -539,9 +543,6 @@ See [issue #41620](https://github.com/rust-lang/rust/issues/41620) for more info
|
|||
|
||||
> **Edition Differences**: Before the 2021 edition, range patterns with both a lower and upper bound may also be written using `...` in place of `..=`, with the same meaning.
|
||||
|
||||
> **Note**: Although range patterns use the same syntax as [range expressions], there are no exclusive range patterns.
|
||||
> That is, neither `x .. y` nor `.. x` are valid range patterns.
|
||||
|
||||
## Reference patterns
|
||||
|
||||
> **<sup>Syntax</sup>**\
|
||||
|
|
Loading…
Reference in New Issue