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

Add help message for missing right operand in condition

closes #30035
This commit is contained in:
Dylan DPC 2020-04-30 20:15:22 +02:00 committed by GitHub
commit be3faf3f30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -1549,6 +1549,11 @@ impl<'a> Parser<'a> {
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
})?;

View File

@ -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