- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Labels
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
This fails (as expected):
fn foo() -> String {
    1 + 2
}
However, the help message is wrong:
error[E0308]: mismatched types
 --> src/lib.rs:2:5
  |
1 | fn foo() -> String {
  |             ------ expected `std::string::String` because of return type
2 |     1 + 2
  |     ^^^^^
  |     |
  |     expected struct `std::string::String`, found integer
  |     help: try using a conversion method: `1 + 2.to_string()`
  |
  = note: expected type `std::string::String`
             found type `{integer}`
It should suggest (1 + 2).to_string() instead.
Rust version: 1.38.0 (stable)
Metadata
Metadata
Assignees
Labels
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.