Skip to content

Commit

Permalink
Rollup merge of rust-lang#109415 - nnethercote:refactor-handle_missin…
Browse files Browse the repository at this point in the history
…g_lit, r=petrochenkov

Refactor `handle_missing_lit`.

A small code readability improvement.

r? `@petrochenkov`
  • Loading branch information
Noratrieb authored Mar 21, 2023
2 parents 27a9dcf + 93eeb12 commit b567a1c
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1843,20 +1843,14 @@ impl<'a> Parser<'a> {
&mut self,
mk_lit_char: impl FnOnce(Symbol, Span) -> L,
) -> PResult<'a, L> {
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) {
let mut err = errors::InvalidInterpolatedExpression { span: self.token.span }
.into_diagnostic(&self.sess.span_diagnostic);
err.downgrade_to_delayed_bug();
return Err(err);
}
}
if let token::Interpolated(nt) = &self.token.kind
&& let token::NtExpr(e) | token::NtLiteral(e) = &**nt
&& matches!(e.kind, ExprKind::Err)
{
let mut err = errors::InvalidInterpolatedExpression { span: self.token.span }
.into_diagnostic(&self.sess.span_diagnostic);
err.downgrade_to_delayed_bug();
return Err(err);
}
let token = self.token.clone();
let err = |self_: &Self| {
Expand Down

0 comments on commit b567a1c

Please sign in to comment.