Closed
Description
Given the following code:
if true { "A".to_string() } else { "B" };
The current output is:
error[E0308]: `if` and `else` have incompatible types
--> src/main.rs:4:40
|
4 | if true { "A".to_string() } else { "B" };
| --------------- --^^^--
| | | |
| | | expected struct `String`, found `&str`
| | help: try using a conversion method: `{ "B" }.to_string()`
| expected because of this
Ideally the output should look like:
error[E0308]: `if` and `else` have incompatible types
--> src/main.rs:4:40
|
4 | if true { "A".to_string() } else { "B" };
| --------------- ^^^
| | |
| | expected struct `String`, found `&str`
| | help: try using a conversion method: `"B".to_string()`
| expected because of this
This might be related to #83320.