Allow underscores in unicode escapes #43692
Labels
A-Unicode
Area: Unicode
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
Underscores are supported in all numeric types in Rust, and a recent clippy update actually warns on not using underscores for long numbers.
However, underscores are not supported for Unicode Escape literals. Therefore, it is not possible to write the first character of the 16th plane as
\u{10_0000}
, while\u{100000}
is not easy to read and can be misread as\u{10000}
.At the moment, underscore results in an error like this:
meaning that there's no backward-compatibility issue and supporting underscores would be a compatible enhancement.
Unicode already has clear definition of Planes, numbered 0 to 16, which hint to write literals as
\u{<plane>_<4-hex-digits>}
sequences.Optionally, we can opt-in to only allow underscore in a specific position, like the aforementioned format. But I think that would just make it too complicate for no apparent reason. Such a check could be a clippy rule, of course.
What do you think?
The text was updated successfully, but these errors were encountered: