1
Fork 0

update and add a few tests

This commit is contained in:
Deadbeef 2023-03-06 07:10:23 +00:00
parent 8ff3903643
commit 76d1f93896
11 changed files with 48 additions and 3 deletions

View file

@ -1814,7 +1814,7 @@ pub enum LitKind {
/// A byte string (`b"foo"`). Not stored as a symbol because it might be
/// non-utf8, and symbols only allow utf8 strings.
ByteStr(Lrc<[u8]>, StrStyle),
/// A C String (`c"foo"`).
/// A C String (`c"foo"`). Guaranteed only have `\0` in the end.
CStr(Lrc<[u8]>, StrStyle),
/// A byte char (`b'f'`).
Byte(u8),

View file

@ -181,7 +181,7 @@ impl LitKind {
}
});
error?;
buf.push(b'\0');
buf.push(0);
LitKind::CStr(buf.into(), StrStyle::Cooked)
}
token::CStrRaw(n) => {
@ -204,7 +204,7 @@ impl LitKind {
}
});
error?;
buf.push(b'\0');
buf.push(0);
LitKind::CStr(buf.into(), StrStyle::Raw(n))
}
token::Err => LitKind::Err,