]>
git.lizzy.rs Git - rust.git/commit
Auto merge of #57230 - estebank:return-mismatch, r=varkor
Modify mismatched type error for functions with no return
Fix #50009.
```
error[E0308]: mismatched types
--> $DIR/coercion-missing-tail-expected-type.rs:3:24
|
LL | fn plus_one(x: i32) -> i32 { //~ ERROR mismatched types
| -------- ^^^ expected i32, found ()
| |
| this function's body doesn't return
LL | x + 1;
| - help: consider removing this semicolon
|
= note: expected type `i32`
found type `()`
```
instead of
```
error[E0308]: mismatched types
--> $DIR/coercion-missing-tail-expected-type.rs:3:28
|
LL | fn plus_one(x: i32) -> i32 { //~ ERROR mismatched types
| ____________________________^
LL | | x + 1;
| | - help: consider removing this semicolon
LL | | }
| |_^ expected i32, found ()
|
= note: expected type `i32`
found type `()`
```