]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #107709 - tialaramex:master, r=compiler-errors
authorMatthias Krüger <matthias.krueger@famsik.de>
Tue, 7 Feb 2023 16:57:17 +0000 (17:57 +0100)
committerGitHub <noreply@github.com>
Tue, 7 Feb 2023 16:57:17 +0000 (17:57 +0100)
commit0e3af6af4708b38065688c6bc4462a916083aff7
tree7e8ed8d904d362bc4b1cfb4ea28e8151eafa4c59
parente45984b7746737feeef1dffe403475b2cc4e68cd
parent747cdc0dfd784c280d50ad50661a1f00a2677842
Rollup merge of #107709 - tialaramex:master, r=compiler-errors

Fix problem noticed in PR106859 with char -> u8 suggestion

HN reader `@ayosec` noticed that my #106859 a few weeks back, malfunctions if you have a Unicode escape, the code suggested b'\u{0}' if you tried to use '\u{0}' where a byte should be, when of course b'\u{0}' is not a byte literal, regardless of the codepoint you can't write Unicode escapes in a byte literal at all.

My proposed fix here just checks that the "character" you wrote is fewer than 5 bytes, thus allowing \x7F and similar escapes but conveniently forbidding even the smallest Unicode escape \u{0} before offering the suggestion as before.

I have provided an updated test which includes examples which do and don't work because of this additional rule.