Closed
Description
When you have
fn foo() -> usize {
""
}
the diagnostic correctly points at the return value
error[E0308]: mismatched types
--> src/main.rs:2:5
|
1 | fn foo() -> usize {
| ----- expected `usize` because of return type
2 | ""
| ^^ expected usize, found reference
|
= note: expected type `usize`
found type `&'static str`
while if the error is due to not having a return value
fn bar() -> usize {
3;
}
error[E0308]: mismatched types
--> src/main.rs:5:19
|
5 | fn bar() -> usize {
| ___________________^
6 | | 3;
| | - help: consider removing this semicolon
7 | | }
| |_^ expected usize, found ()
|
= note: expected type `usize`
found type `()`
It probably should be
error[E0308]: mismatched types
--> src/main.rs:5:19
|
5 | fn bar() -> usize {
| ----- expected due to this return type
6 | 3;
| ^- help: consider removing this semicolon
| |
| expected usize, found ()
|
= note: expected type `usize`
found type `()`