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:
@@ -2140,12 +2140,12 @@ impl<'a> Parser<'a> {
|
||||
Err(err) => {
|
||||
let span = token.uninterpolated_span();
|
||||
self.bump();
|
||||
report_lit_error(self.sess, err, lit, span);
|
||||
let guar = report_lit_error(self.sess, err, lit, span);
|
||||
// Pack possible quotes and prefixes from the original literal into
|
||||
// the error literal's symbol so they can be pretty-printed faithfully.
|
||||
let suffixless_lit = token::Lit::new(lit.kind, lit.symbol, None);
|
||||
let symbol = Symbol::intern(&suffixless_lit.to_string());
|
||||
let lit = token::Lit::new(token::Err, symbol, lit.suffix);
|
||||
let lit = token::Lit::new(token::Err(guar), symbol, lit.suffix);
|
||||
Some(
|
||||
MetaItemLit::from_token_lit(lit, span)
|
||||
.unwrap_or_else(|_| unreachable!()),
|
||||
|
||||
Reference in New Issue
Block a user