Confusing error message when collecting an iterator of results into a single result #60440
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-iterators
Area: Iterators
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
F-on_unimplemented
Error messages that can be tackled with `#[rustc_on_unimplemented]`
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
The code:
Produces this error:
The message sounds very strange because a collection with elements of type
i32
certainly can be built from an iterator over elements of typei32
. The real problem is that a value of typei32
cannot be unambiguously built from an iterator over elements of typei32
, because a folding function would need to be provided for it to make sense.In cases where you are trying to collect into a non-collection type, the message should use a different word, probably "value".
The text was updated successfully, but these errors were encountered: