diff options
| author | bors <bors@rust-lang.org> | 2021-09-24 01:48:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-09-24 01:48:02 +0000 |
| commit | 293b8f2c11cbec03f0d4daae6b82ed7541ebbf4e (patch) | |
| tree | 8b2059d304cdf68e31a428247287d154f02c75fa /compiler/rustc_parse/src/parser | |
| parent | 900cf5e8905ba8a2a9c99a1dfc9cb2cf4754d77a (diff) | |
| parent | 1875cecfd46a347dac9c9e23910e4b39be3a9d5f (diff) | |
| download | rust-293b8f2c11cbec03f0d4daae6b82ed7541ebbf4e.tar.gz rust-293b8f2c11cbec03f0d4daae6b82ed7541ebbf4e.zip | |
Auto merge of #89211 - workingjubilee:rollup-fj4eduk, r=workingjubilee
Rollup of 7 pull requests Successful merges: - #88612 (Add a better error message for #39364) - #89023 (Resolve issue : Somewhat confusing error with extended_key_value_attributes) - #89148 (Suggest `_` in turbofish if param will be inferred from fn argument) - #89171 (Run `no_core` rustdoc tests only on Linux) - #89176 (Change singular to plural) - #89184 (Temporarily rename int_roundings functions to avoid conflicts) - #89200 (Fix typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
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) }) |
