]> git.lizzy.rs Git - rust.git/commit
Make non-ASCII errors more consistent.
authorNicholas Nethercote <n.nethercote@gmail.com>
Thu, 3 Nov 2022 04:17:37 +0000 (15:17 +1100)
committerNicholas Nethercote <n.nethercote@gmail.com>
Fri, 4 Nov 2022 03:23:40 +0000 (14:23 +1100)
commit7dbf2c0ed86a6fc97aa0b93bc2ac865d6f2cc438
tree95b18ce5f8af6693f1484490d128a95b919fd38b
parent34b32b0dac9da3fad7861bdc2bad89d771172bb3
Make non-ASCII errors more consistent.

There are three kinds of "byte" literals: byte literals, byte string
literals, and raw byte string literals. None are allowed to have
non-ASCII chars in them.

Two `EscapeError` variants exist for when that constraint is violated.
- `NonAsciiCharInByte`: used for byte literals and byte string literals.
- `NonAsciiCharInByteString`: used for raw byte string literals.

As a result, the messages for raw byte string literals use different
wording, without good reason. Also, byte string literals are incorrectly
described as "byte constants" in some error messages.

This commit eliminates `NonAsciiCharInByteString` so the three cases are
handled similarly, and described correctly. The `mode` is enough to
distinguish them.

Note: Some existing error messages mention "byte constants" and some
mention "byte literals". I went with the latter here, because it's a
more correct name, as used by the Reference.
15 files changed:
compiler/rustc_lexer/src/unescape.rs
compiler/rustc_lexer/src/unescape/tests.rs
compiler/rustc_parse/src/lexer/unescape_error_reporting.rs
src/test/ui/attributes/key-value-non-ascii.rs
src/test/ui/attributes/key-value-non-ascii.stderr
src/test/ui/parser/byte-literals.rs
src/test/ui/parser/byte-literals.stderr
src/test/ui/parser/byte-string-literals.rs
src/test/ui/parser/byte-string-literals.stderr
src/test/ui/parser/raw/raw-byte-string-literals.rs
src/test/ui/parser/raw/raw-byte-string-literals.stderr
src/test/ui/parser/unicode-control-codepoints.rs
src/test/ui/parser/unicode-control-codepoints.stderr
src/test/ui/suggestions/multibyte-escapes.rs
src/test/ui/suggestions/multibyte-escapes.stderr