Resolve issue 85066

Fix : use struct_dummy

Fix different os messages
This commit is contained in:
Theo 2021-09-16 21:00:11 +02:00
parent 2b5ddf36fd
commit 250a3e482f
3 changed files with 32 additions and 0 deletions

View file

@ -1493,6 +1493,20 @@ impl<'a> Parser<'a> {
pub(super) fn parse_lit(&mut self) -> PResult<'a, Lit> {
self.parse_opt_lit().ok_or_else(|| {
if let token::Interpolated(inner) = &self.token.kind {
let expr = match inner.as_ref() {
token::NtExpr(expr) => Some(expr),
token::NtLiteral(expr) => Some(expr),
_ => None,
};
if let Some(expr) = expr {
if matches!(expr.kind, ExprKind::Err) {
self.diagnostic()
.delay_span_bug(self.token.span, &"invalid interpolated expression");
return self.diagnostic().struct_dummy();
}
}
}
let msg = format!("unexpected token: {}", super::token_descr(&self.token));
self.struct_span_err(self.token.span, &msg)
})