diff options
| author | Takashi Idobe <idobetakashi@gmail.com> | 2021-09-24 08:31:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-24 08:31:03 -0500 |
| commit | cb1c06fdd8921071a353b70d4752d834a76c5f94 (patch) | |
| tree | d4606b4bee7f5dd22f5a0122fa5796961b815a60 /compiler/rustc_parse/src/parser | |
| parent | b146525140a8776aec1f7852643ec2abd787a197 (diff) | |
| parent | 91d8da1f4ba24679e92b7939a26c681a5d2d3548 (diff) | |
| download | rust-cb1c06fdd8921071a353b70d4752d834a76c5f94.tar.gz rust-cb1c06fdd8921071a353b70d4752d834a76c5f94.zip | |
Merge branch 'rust-lang:master' into master
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -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) }) |
