未验证 提交 be3faf3f 编写于 作者: D Dylan DPC 提交者: GitHub

Rollup merge of #71433 - antoyo:error/missing-right-operand, r=Dylan-DPC

Add help message for missing right operand in condition

closes #30035
......@@ -1549,6 +1549,11 @@ fn parse_if_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
let block = self.parse_block().map_err(|mut err| {
if not_block {
err.span_label(lo, "this `if` expression has a condition, but no block");
if let ExprKind::Binary(_, _, ref right) = cond.kind {
if let ExprKind::Block(_, _) = right.kind {
err.help("maybe you forgot the right operand of the condition?");
}
}
}
err
})?;
......
......@@ -6,6 +6,8 @@ LL | if 5 == {
...
LL | }
| ^ expected `{`
|
= help: maybe you forgot the right operand of the condition?
error: aborting due to previous error
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册