Refactor handle_missing_lit
.
This commit is contained in:
parent
8826b68c62
commit
93eeb12724
@ -1843,20 +1843,14 @@ fn handle_missing_lit<L>(
|
|||||||
&mut self,
|
&mut self,
|
||||||
mk_lit_char: impl FnOnce(Symbol, Span) -> L,
|
mk_lit_char: impl FnOnce(Symbol, Span) -> L,
|
||||||
) -> PResult<'a, L> {
|
) -> PResult<'a, L> {
|
||||||
if let token::Interpolated(inner) = &self.token.kind {
|
if let token::Interpolated(nt) = &self.token.kind
|
||||||
let expr = match inner.as_ref() {
|
&& let token::NtExpr(e) | token::NtLiteral(e) = &**nt
|
||||||
token::NtExpr(expr) => Some(expr),
|
&& matches!(e.kind, ExprKind::Err)
|
||||||
token::NtLiteral(expr) => Some(expr),
|
{
|
||||||
_ => None,
|
let mut err = errors::InvalidInterpolatedExpression { span: self.token.span }
|
||||||
};
|
.into_diagnostic(&self.sess.span_diagnostic);
|
||||||
if let Some(expr) = expr {
|
err.downgrade_to_delayed_bug();
|
||||||
if matches!(expr.kind, ExprKind::Err) {
|
return Err(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 token = self.token.clone();
|
||||||
let err = |self_: &Self| {
|
let err = |self_: &Self| {
|
||||||
|
Loading…
Reference in New Issue
Block a user