Skip to content

Commit dd3b76d

Browse files
committed
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.
1 parent 10446e7 commit dd3b76d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

proc_macro/src/bridge/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,11 @@ pub enum LitKind {
337337
ByteStrRaw(u8),
338338
CStr,
339339
CStrRaw(u8),
340-
Err,
340+
// This should have an `ErrorGuaranteed`, except that type isn't available
341+
// in this crate. (Imagine it is there.) Hence the `WithGuar` suffix. Must
342+
// only be constructed in `LitKind::from_internal`, where an
343+
// `ErrorGuaranteed` is available.
344+
ErrWithGuar,
341345
}
342346

343347
rpc_encode_decode!(
@@ -352,7 +356,7 @@ rpc_encode_decode!(
352356
ByteStrRaw(n),
353357
CStr,
354358
CStrRaw(n),
355-
Err,
359+
ErrWithGuar,
356360
}
357361
);
358362

proc_macro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ impl Literal {
14511451
f(&["cr", hashes, "\"", symbol, "\"", hashes, suffix])
14521452
}
14531453

1454-
bridge::LitKind::Integer | bridge::LitKind::Float | bridge::LitKind::Err => {
1454+
bridge::LitKind::Integer | bridge::LitKind::Float | bridge::LitKind::ErrWithGuar => {
14551455
f(&[symbol, suffix])
14561456
}
14571457
})

0 commit comments

Comments
 (0)