1
Fork 0

Add ErrorGuaranteed to ast::LitKind::Err, token::LitKind::Err.

This mostly works well, and eliminates a couple of delayed bugs.

One annoying thing is that we should really also add an
`ErrorGuaranteed` to `proc_macro::bridge::LitKind::Err`. But that's
difficult because `proc_macro` doesn't have access to `ErrorGuaranteed`,
so we have to fake it.
This commit is contained in:
Nicholas Nethercote 2024-02-14 20:12:05 +11:00
parent 332c57723a
commit 25ed6e43b0
26 changed files with 85 additions and 64 deletions

View file

@ -337,7 +337,11 @@ pub enum LitKind {
ByteStrRaw(u8),
CStr,
CStrRaw(u8),
Err,
// This should have an `ErrorGuaranteed`, except that type isn't available
// in this crate. (Imagine it is there.) Hence the `WithGuar` suffix. Must
// only be constructed in `LitKind::from_internal`, where an
// `ErrorGuaranteed` is available.
ErrWithGuar,
}
rpc_encode_decode!(
@ -352,7 +356,7 @@ rpc_encode_decode!(
ByteStrRaw(n),
CStr,
CStrRaw(n),
Err,
ErrWithGuar,
}
);

View file

@ -1451,7 +1451,7 @@ impl Literal {
f(&["cr", hashes, "\"", symbol, "\"", hashes, suffix])
}
bridge::LitKind::Integer | bridge::LitKind::Float | bridge::LitKind::Err => {
bridge::LitKind::Integer | bridge::LitKind::Float | bridge::LitKind::ErrWithGuar => {
f(&[symbol, suffix])
}
})