Repository navigation
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.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
Code
fn main() {
let input = "lowercase";
let uppercase: String = input.chars().map(|c| c.to_ascii_uppercase());
}Current output
error[E0308]: mismatched types
--> $DIR/string-from-char-iterator-without-collect.rs:10:29
|
LL | let uppercase: String = input.chars().map(|c| c.to_ascii_uppercase());
| ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `String`, found `Map<Chars<'_>, {closure@...}>`
| |
| expected due to this
|
= note: expected struct `String`
found struct `Map<Chars<'_>, {closure@$DIR/string-from-char-iterator-without-collect.rs:10:47: 10:50}>`Desired output
error[E0308]: mismatched types
--> $DIR/string-from-char-iterator-without-collect.rs:10:29
|
LL | let uppercase: String = input.chars().map(|c| c.to_ascii_uppercase());
| ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `String`, found `Map<Chars<'_>, {closure@...}>`
| |
| expected due to this
|
= note: expected struct `String`
found struct `Map<Chars<'_>, {closure@$DIR/string-from-char-iterator-without-collect.rs:10:47: 10:50}>`
help: you can collect the `Iterator<Item = char>` into a `String`
|
LL | let uppercase: String = input.chars().map(|c| c.to_ascii_uppercase()).collect();
| ++++++++++Rationale and extra context
No response
Other cases
Rust Version
1.97Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.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.
Activity
mejrs commentedon Jul 19, 2026
Fixed in #156121