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.
22 lines
577 B
Text
22 lines
577 B
Text
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`.
|