diff options
| author | Jubilee <46493976+workingjubilee@users.noreply.github.com> | 2021-09-23 17:31:42 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-23 17:31:42 -0700 |
| commit | 5da2f460b36988d5e0226412080769bafd94eb3c (patch) | |
| tree | dcba832ce3fe003e824c0bc474929385d9122437 /compiler/rustc_parse | |
| parent | 586d028d0e32773a5ae5602f38e2751d7dd25523 (diff) | |
| parent | 250a3e482f125e96b37d66d6d87be7b09436be5c (diff) | |
| download | rust-5da2f460b36988d5e0226412080769bafd94eb3c.tar.gz rust-5da2f460b36988d5e0226412080769bafd94eb3c.zip | |
Rollup merge of #89023 - Wardenfar:issue-85066, r=nagisa
Resolve issue : Somewhat confusing error with extended_key_value_attributes Fixes #85066
Diffstat (limited to 'compiler/rustc_parse')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index fe0468c6956..c5417ea23f2 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1568,6 +1568,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) }) |
