Closed
Description
Consider this code:
fn main() {
b'字';
b"字";
}
The current output is:
error: non-ASCII character in byte constant
--> src/main.rs:2:7
|
2 | b'字';
| ^^
| |
| byte constant must be ASCII
| help: use a \xHH escape for a non-ASCII byte: `\x5B57`
error: non-ASCII character in byte constant
--> src/main.rs:3:7
|
3 | b"字";
| ^^
| |
| byte constant must be ASCII
| help: use a \xHH escape for a non-ASCII byte: `\x5B57`
error: could not compile `playground` due to 2 previous errors
The suggestions are incorrect: \x5B57
is not a valid escaped character, only the \x5B
part is interpreted as an escaped character while the 57
part is interpreted as two normal characters.
In the case of byte characters the suggestion leads to a byte character literal with more than one character, thus in another compile error. However in the case of byte strings this will silently compile, even though that probably wasn't what the user wanted nor expected.
This happens in both the current stable and nightly compilers.