fn loop_ending() -> i32 {
loop {
if false { break; }
return 42;
}
}
produces
error[E0308]: mismatched types
--> <anon>:2:5
|
2 | loop {
| _____^ starting here...
3 | | if false { break; }
4 | | return 42;
5 | | }
| |_____^ ...ending here: expected i32, found ()
|
= note: expected type `i32`
= note: found type `()`
error: aborting due to previous error
But the compiler can check that the final expression is a loop and must always evaluate into (), so we can recommend more advanced information.
This has caused real confusion.
produces
But the compiler can check that the final expression is a loop and must always evaluate into
(), so we can recommend more advanced information.This has caused real confusion.