always return ExprKind::Err

This commit is contained in:
darklyspaced 2023-08-07 22:32:28 +08:00
parent 9ed5267e61
commit 13ac0234c6
No known key found for this signature in database

View File

@ -1717,12 +1717,7 @@ impl<'a> Parser<'a> {
self.recover_await_prefix(await_sp)? self.recover_await_prefix(await_sp)?
}; };
let sp = self.error_on_incorrect_await(lo, hi, &expr, is_question); let sp = self.error_on_incorrect_await(lo, hi, &expr, is_question);
let kind = match expr.kind { let kind = ExprKind::Err;
// Avoid knock-down errors as we don't know whether to interpret this as `foo().await?`
// or `foo()?.await` (the very reason we went with postfix syntax 😅).
ExprKind::Try(_) => ExprKind::Err,
_ => ExprKind::Await(expr, await_sp),
};
let expr = self.mk_expr(lo.to(sp), kind); let expr = self.mk_expr(lo.to(sp), kind);
self.maybe_recover_from_bad_qpath(expr) self.maybe_recover_from_bad_qpath(expr)
} }