mirror of https://github.com/rust-lang/reference
Escape brackets so they don't appear like a broken link reference.
This commit is contained in:
parent
46b66c8005
commit
dd1b9c331e
|
@ -2,27 +2,27 @@
|
|||
|
||||
> **<sup>Lexer</sup>**\
|
||||
> LINE_COMMENT :\
|
||||
> `//` (~[`/` `!`] | `//`) ~`\n`<sup>\*</sup>\
|
||||
> `//` (~\[`/` `!`] | `//`) ~`\n`<sup>\*</sup>\
|
||||
> | `//`
|
||||
>
|
||||
> BLOCK_COMMENT :\
|
||||
> `/*` (~[`*` `!`] | `**` | _BlockCommentOrDoc_)
|
||||
> `/*` (~\[`*` `!`] | `**` | _BlockCommentOrDoc_)
|
||||
> (_BlockCommentOrDoc_ | ~`*/`)<sup>\*</sup> `*/`\
|
||||
> | `/**/`\
|
||||
> | `/***/`
|
||||
>
|
||||
> INNER_LINE_DOC :\
|
||||
> `//!` ~[`\n` _IsolatedCR_]<sup>\*</sup>
|
||||
> `//!` ~\[`\n` _IsolatedCR_]<sup>\*</sup>
|
||||
>
|
||||
> INNER_BLOCK_DOC :\
|
||||
> `/*!` ( _BlockCommentOrDoc_ | ~[`*/` _IsolatedCR_] )<sup>\*</sup> `*/`
|
||||
> `/*!` ( _BlockCommentOrDoc_ | ~\[`*/` _IsolatedCR_] )<sup>\*</sup> `*/`
|
||||
>
|
||||
> OUTER_LINE_DOC :\
|
||||
> `///` (~`/` ~[`\n` _IsolatedCR_]<sup>\*</sup>)<sup>?</sup>
|
||||
> `///` (~`/` ~\[`\n` _IsolatedCR_]<sup>\*</sup>)<sup>?</sup>
|
||||
>
|
||||
> OUTER_BLOCK_DOC :\
|
||||
> `/**` (~`*` | _BlockCommentOrDoc_ )
|
||||
> (_BlockCommentOrDoc_ | ~[`*/` _IsolatedCR_])<sup>\*</sup> `*/`
|
||||
> (_BlockCommentOrDoc_ | ~\[`*/` _IsolatedCR_])<sup>\*</sup> `*/`
|
||||
>
|
||||
> _BlockCommentOrDoc_ :\
|
||||
> BLOCK_COMMENT\
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
> **<sup>Lexer:<sup>**\
|
||||
> IDENTIFIER_OR_KEYWORD :\
|
||||
> [`a`-`z` `A`-`Z`] [`a`-`z` `A`-`Z` `0`-`9` `_`]<sup>\*</sup>\
|
||||
> | `_` [`a`-`z` `A`-`Z` `0`-`9` `_`]<sup>+</sup>
|
||||
> \[`a`-`z` `A`-`Z`] \[`a`-`z` `A`-`Z` `0`-`9` `_`]<sup>\*</sup>\
|
||||
> | `_` \[`a`-`z` `A`-`Z` `0`-`9` `_`]<sup>+</sup>
|
||||
>
|
||||
> RAW_IDENTIFIER : `r#` IDENTIFIER_OR_KEYWORD <sub>*Except `crate`, `self`, `super`, `Self`*</sub>
|
||||
>
|
||||
|
|
|
@ -15,9 +15,9 @@ The following notations are used by the *Lexer* and *Syntax* grammar snippets:
|
|||
| x<sup>+</sup> | _MacroMatch_<sup>+</sup> | 1 or more of x |
|
||||
| x<sup>a..b</sup> | HEX_DIGIT<sup>1..6</sup> | a to b repetitions of x |
|
||||
| \| | `u8` \| `u16`, Block \| Item | Either one or another |
|
||||
| [ ] | [`b` `B`] | Any of the characters listed |
|
||||
| [ - ] | [`a`-`z`] | Any of the characters in the range |
|
||||
| ~[ ] | ~[`b` `B`] | Any characters, except those listed |
|
||||
| \[ ] | \[`b` `B`] | Any of the characters listed |
|
||||
| \[ - ] | \[`a`-`z`] | Any of the characters in the range |
|
||||
| ~\[ ] | ~\[`b` `B`] | Any characters, except those listed |
|
||||
| ~`string` | ~`\n`, ~`*/` | Any characters, except this sequence |
|
||||
| ( ) | (`,` _Parameter_)<sup>?</sup> | Groups items |
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ and numeric literal tokens are accepted only with suffixes from the list below.
|
|||
|
||||
> **<sup>Lexer</sup>**\
|
||||
> CHAR_LITERAL :\
|
||||
> `'` ( ~[`'` `\` \\n \\r \\t] | QUOTE_ESCAPE | ASCII_ESCAPE | UNICODE_ESCAPE ) `'`
|
||||
> `'` ( ~\[`'` `\` \\n \\r \\t] | QUOTE_ESCAPE | ASCII_ESCAPE | UNICODE_ESCAPE ) `'`
|
||||
>
|
||||
> QUOTE_ESCAPE :\
|
||||
> `\'` | `\"`
|
||||
|
@ -136,7 +136,7 @@ which must be _escaped_ by a preceding `U+005C` character (`\`).
|
|||
> **<sup>Lexer</sup>**\
|
||||
> STRING_LITERAL :\
|
||||
> `"` (\
|
||||
> ~[`"` `\` _IsolatedCR_]\
|
||||
> ~\[`"` `\` _IsolatedCR_]\
|
||||
> | QUOTE_ESCAPE\
|
||||
> | ASCII_ESCAPE\
|
||||
> | UNICODE_ESCAPE\
|
||||
|
@ -338,13 +338,13 @@ literal_. The grammar for recognizing the two kinds of literals is mixed.
|
|||
> HEX_LITERAL :\
|
||||
> `0x` (HEX_DIGIT|`_`)<sup>\*</sup> HEX_DIGIT (HEX_DIGIT|`_`)<sup>\*</sup>
|
||||
>
|
||||
> BIN_DIGIT : [`0`-`1`]
|
||||
> BIN_DIGIT : \[`0`-`1`]
|
||||
>
|
||||
> OCT_DIGIT : [`0`-`7`]
|
||||
> OCT_DIGIT : \[`0`-`7`]
|
||||
>
|
||||
> DEC_DIGIT : [`0`-`9`]
|
||||
> DEC_DIGIT : \[`0`-`9`]
|
||||
>
|
||||
> HEX_DIGIT : [`0`-`9` `a`-`f` `A`-`F`]
|
||||
> HEX_DIGIT : \[`0`-`9` `a`-`f` `A`-`F`]
|
||||
>
|
||||
> INTEGER_SUFFIX :\
|
||||
> `u8` | `u16` | `u32` | `u64` | `u128` | `usize`\
|
||||
|
|
|
@ -177,7 +177,7 @@ for interfacing with the C programming language.
|
|||
This representation can be applied to structs, unions, and enums. The exception
|
||||
is [zero-variant enums] for which the `C` representation is an error.
|
||||
|
||||
#### \#[repr(C)] Structs
|
||||
#### `#[repr(C)]` Structs
|
||||
|
||||
The alignment of the struct is the alignment of the most-aligned field in it.
|
||||
|
||||
|
@ -244,7 +244,7 @@ the sake of clarity. To perform memory layout computations in actual code, use
|
|||
> they are fields that have the `[[no_unique_address]]` attribute, in which
|
||||
> case they do not increase the overall size of the struct.
|
||||
|
||||
#### \#[repr(C)] Unions
|
||||
#### `#[repr(C)]` Unions
|
||||
|
||||
A union declared with `#[repr(C)]` will have the same size and alignment as an
|
||||
equivalent C union declaration in the C language for the target platform.
|
||||
|
@ -274,7 +274,7 @@ assert_eq!(std::mem::size_of::<SizeRoundedUp>(), 8); // Size of 6 from b,
|
|||
assert_eq!(std::mem::align_of::<SizeRoundedUp>(), 4); // From a
|
||||
```
|
||||
|
||||
#### \#[repr(C)] Field-less Enums
|
||||
#### `#[repr(C)]` Field-less Enums
|
||||
|
||||
For [field-less enums], the `C` representation has the size and alignment of
|
||||
the default `enum` size and alignment for the target platform's C ABI.
|
||||
|
@ -295,7 +295,7 @@ using a field-less enum in FFI to model a C `enum` is often wrong.
|
|||
|
||||
</div>
|
||||
|
||||
#### \#[repr(C)] Enums With Fields
|
||||
#### `#[repr(C)]` Enums With Fields
|
||||
|
||||
The representation of a `repr(C)` enum with fields is a `repr(C)` struct with
|
||||
two fields, also called a "tagged union" in C:
|
||||
|
@ -433,7 +433,7 @@ struct MyVariantD(MyEnumDiscriminant);
|
|||
|
||||
> Note: `union`s with non-`Copy` fields are unstable, see [55149].
|
||||
|
||||
#### Combining primitive representations of enums with fields and \#[repr(C)]
|
||||
#### Combining primitive representations of enums with fields and `#[repr(C)]`
|
||||
|
||||
For enums with fields, it is also possible to combine `repr(C)` and a
|
||||
primitive representation (e.g., `repr(C, u8)`). This modifies the [`repr(C)`] by
|
||||
|
|
Loading…
Reference in New Issue