Use unescape_unicode for raw C string literals.

They can't contain `\x` escapes, which means they can't contain high
bytes, which means we can used `unescape_unicode` instead of
`unescape_mixed` to unescape them. This avoids unnecessary used of
`MixedUnit`.
This commit is contained in:
Nicholas Nethercote 2024-01-24 16:00:10 +11:00
parent 86f371ed59
commit 6be2e5623c
2 changed files with 15 additions and 20 deletions

View file

@ -472,7 +472,7 @@ impl<'sess, 'src> StringReader<'sess, 'src> {
if let Some(n_hashes) = n_hashes {
let n = u32::from(n_hashes);
let kind = token::CStrRaw(n_hashes);
self.cook_mixed(kind, Mode::RawCStr, start, end, 3 + n, 1 + n) // cr##" "##
self.cook_unicode(kind, Mode::RawCStr, start, end, 3 + n, 1 + n) // cr##" "##
} else {
self.report_raw_str_error(start, 2);
}