Closed
Description
fn main() { //~ NOTE expected `()` because of default return type
let s = "abc";
let u: &str = if true { s[..2] } else { s };
}
has an incorrect label:
error[E0308]: mismatched types
--> src/main.rs:3:27
|
1 | fn main() { //~ NOTE expected `()` because of default return type
| - expected `()` because of default return type
2 | let s = "abc";
3 | let u: &str = if true { s[..2] } else { s };
| ^^^^^^ expected &str, found str
|
= note: expected type `&str`
found type `str`