Closed
Description
Code
fn main() {
if true {
""
}
}
Current output
error[E0308]: mismatched types
--> src/main.rs:3:9
|
1 | fn main() {
| - expected `()` because of default return type
2 | if true {
3 | ""
| ^^ expected `()`, found `&str`
Desired output
error[E0308]: mismatched types
--> src/main.rs:3:9
|
2 | / if true {
3 | | ""
| | ^^ expected `()`, found `&str`
4 | | }
| |_____- expected this to be `()`
Rationale and extra context
When the if
is not the tail expression, we provide the right output. We might just have to change the order of operation when looking for additional context to print.
Other cases
if true { "" } else { "" }
as tail expression has the same problem.
Rust Version
All checked, current version 1.78.