You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This changes underscore from being a punctuation character to a keyword.
This is intended to help better align with proc-macros, which treat it
as an [`Ident`](https://doc.rust-lang.org/proc_macro/struct.Ident.html).
Note one unusual rule is inline assembly `ParamName` which is
`IDENTIFIER_OR_KEYWORD`. From what I can tell, it does accept `_`, but
the fmt template does not. Templates are not specified in great detail
in the std docs, and don't touch on this fact.
Closes#1236Closes#2020
NON_KEYWORD_IDENTIFIER -> IDENTIFIER_OR_KEYWORD _except a [strict][lex.keywords.strict] or [reserved][lex.keywords.reserved] keyword_
17
15
@@ -37,8 +35,6 @@ The profile used from UAX #31 is:
37
35
* Continue := [`XID_Continue`]
38
36
* Medial := empty
39
37
40
-
with the additional constraint that a single underscore character is not an identifier.
41
-
42
38
> [!NOTE]
43
39
> Identifiers starting with an underscore are typically used to indicate an identifier that is intentionally unused, and will silence the unused warning in `rustc`.
Some lexical forms known as _reserved prefixes_ are reserved for future use.
964
961
965
962
r[lex.token.reserved-prefix.id]
966
-
Source input which would otherwise be lexically interpreted as a non-raw identifier (or a keyword or `_`) which is immediately followed by a `#`, `'`, or `"` character (without intervening whitespace) is identified as a reserved prefix.
963
+
Source input which would otherwise be lexically interpreted as a non-raw identifier (or a keyword) which is immediately followed by a `#`, `'`, or `"` character (without intervening whitespace) is identified as a reserved prefix.
967
964
968
965
r[lex.token.reserved-prefix.raw-token]
969
966
Note that raw identifiers, raw string literals, and raw byte string literals may contain a `#` character but are not interpreted as containing a reserved prefix.
Similarly the `r`, `b`, `br`, `c`, and `cr` prefixes used in raw string literals, byte literals, byte string literals, raw byte string literals, C string literals, and raw C string literals are not interpreted as reserved prefixes.
973
970
974
971
r[lex.token.reserved-prefix.life]
975
-
Source input which would otherwise be lexically interpreted as a non-raw lifetime (or a keyword or `_`) which is immediately followed by a `#` character (without intervening whitespace) is identified as a reserved lifetime prefix.
972
+
Source input which would otherwise be lexically interpreted as a non-raw lifetime (or a keyword) which is immediately followed by a `#` character (without intervening whitespace) is identified as a reserved lifetime prefix.
0 commit comments