- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.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
Given the following code: play
fn f() {
    vec!['a'].iter().map(|c| c)
}The current output is:
error[E0308]: mismatched types
 --> src/lib.rs:2:5
  |
2 |     vec!['a'].iter().map(|c| c)
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found struct `Map`
  |
  = note: expected unit type `()`
                found struct `Map<std::slice::Iter<'_, char>, [closure@src/lib.rs:2:26: 2:31]>`
help: consider using a semicolon here
  |
2 |     vec!['a'].iter().map(|c| c);
  |                                +
help: try adding a return type
  |
1 | fn f() -> Map<std::slice::Iter<'_, char>, [closure@src/lib.rs:2:26: 2:31]> {
  |        +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ideally the output should look like:
Don't suggest adding -> Map<std::slice::Iter<'_, char>, [closure@src/lib.rs:2:26: 2:31]> if that's not going to compile.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.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.