Skip to content

Commit 3778433

Browse files
committed
Add identifier syntax to identifiers.md
1 parent 0b18ee6 commit 3778433

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/identifiers.md

Lines changed: 24 additions & 0 deletions
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,28 +36,47 @@ 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

48+
r[ident.ascii-extern-crate]
4049
* [`extern crate`] declarations
50+
51+
r[ident.ascii-extern-prelude]
4152
* External crate names referenced in a [path]
53+
54+
r[ident.ascii-outlined-module]
4255
* [Module] names loaded from the filesystem without a [`path` attribute]
56+
57+
r[ident.ascii-no_mangle]
4358
* [`no_mangle`] attributed items
59+
60+
r[ident.ascii-extern-item]
4461
* Item names in [external blocks]
4562

4663
## Normalization
4764

65+
r[ident.normalize]
66+
4867
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.
4968

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

5271
## Raw identifiers
5372

73+
r[ident.raw]
74+
75+
r[ident.raw.intro]
5476
A raw identifier is like a normal identifier, but prefixed by `r#`. (Note that
5577
the `r#` prefix is not included as part of the actual identifier.)
78+
79+
r[ident.raw.allowed]
5680
Unlike a normal identifier, a raw identifier may be any strict or reserved
5781
keyword except the ones listed above for `RAW_IDENTIFIER`.
5882

0 commit comments

Comments
 (0)