Skip to content

Commit 46d65f8

Browse files
authored
Merge pull request #1583 from chorman0773/spec-add-identifiers-identifiers
Add identifier syntax to identifiers.md
2 parents 24deb91 + 02596d2 commit 46d65f8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/identifiers.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Identifiers
22

3+
r[ident]
4+
5+
r[ident.syntax]
36
> **<sup>Lexer:<sup>**\
47
> IDENTIFIER_OR_KEYWORD :\
58
> &nbsp;&nbsp; &nbsp;&nbsp; XID_Start XID_Continue<sup>\*</sup>\
@@ -13,6 +16,7 @@
1316
> NON_KEYWORD_IDENTIFIER | RAW_IDENTIFIER
1417
1518
<!-- When updating the version, update the UAX links, too. -->
19+
r[ident.unicode]
1620
Identifiers follow the specification in [Unicode Standard Annex #31][UAX31] for Unicode version 15.0, with the additions described below. Some examples of identifiers:
1721

1822
* `foo`
@@ -21,6 +25,7 @@ Identifiers follow the specification in [Unicode Standard Annex #31][UAX31] for
2125
* `Москва`
2226
* `東京`
2327

28+
r[ident.profile]
2429
The profile used from UAX #31 is:
2530

2631
* Start := [`XID_Start`], plus the underscore character (U+005F)
@@ -31,10 +36,13 @@ with the additional constraint that a single underscore character is not an iden
3136

3237
> **Note**: Identifiers starting with an underscore are typically used to indicate an identifier that is intentionally unused, and will silence the unused warning in `rustc`.
3338
39+
r[ident.keyword]
3440
Identifiers may not be a [strict] or [reserved] keyword without the `r#` prefix described below in [raw identifiers](#raw-identifiers).
3541

42+
r[ident.zero-width-chars]
3643
Zero width non-joiner (ZWNJ U+200C) and zero width joiner (ZWJ U+200D) characters are not allowed in identifiers.
3744

45+
r[ident.ascii-limitations]
3846
Identifiers are restricted to the ASCII subset of [`XID_Start`] and [`XID_Continue`] in the following situations:
3947

4048
* [`extern crate`] declarations
@@ -45,14 +53,21 @@ Identifiers are restricted to the ASCII subset of [`XID_Start`] and [`XID_Contin
4553

4654
## Normalization
4755

56+
r[ident.normalization]
57+
4858
Identifiers are normalized using Normalization Form C (NFC) as defined in [Unicode Standard Annex #15][UAX15]. Two identifiers are equal if their NFC forms are equal.
4959

5060
[Procedural][proc-macro] and [declarative][mbe] macros receive normalized identifiers in their input.
5161

5262
## Raw identifiers
5363

64+
r[ident.raw]
65+
66+
r[ident.raw.intro]
5467
A raw identifier is like a normal identifier, but prefixed by `r#`. (Note that
5568
the `r#` prefix is not included as part of the actual identifier.)
69+
70+
r[ident.raw.allowed]
5671
Unlike a normal identifier, a raw identifier may be any strict or reserved
5772
keyword except the ones listed above for `RAW_IDENTIFIER`.
5873

0 commit comments

Comments
 (0)