rust/src/test/ui/issues/issue-4201.stderr
bors 86466a397a Auto merge of #58981 - estebank:elseless-if, r=davidtwco
Point at coercion reason for `if` expressions without else clause if caused by return type

```
error[E0317]: if may be missing an else clause
  --> $DIR/if-without-else-as-fn-expr.rs:2:5
   |
LL |   fn foo(bar: usize) -> usize {
   |                         ----- found `usize` because of this return type
LL | /     if bar % 5 == 0 {
LL | |         return 3;
LL | |     }
   | |_____^ expected (), found usize
   |
   = note: expected type `()`
              found type `usize`
   = note: `if` expressions without `else` must evaluate to `()`
```

Fix #25228.
2019-03-21 23:42:41 +00:00

23 lines
577 B
Plaintext

error[E0317]: if may be missing an else clause
--> $DIR/issue-4201.rs:4:12
|
LL | } else if false {
| ____________^
LL | |
LL | |
LL | |
LL | |
LL | | 1
| | - found here
LL | | };
| |_____^ expected (), found integer
|
= note: expected type `()`
found type `{integer}`
= note: `if` expressions without `else` evaluate to `()`
= help: consider adding an `else` block that evaluates to the expected type
error: aborting due to previous error
For more information about this error, try `rustc --explain E0317`.