Closed
Description
This code:
fn main() -> Result<(), ()> {
vec![Ok(2)].into_iter().collect()?;
Ok(())
}
gives a terrible error:
error[E0284]: type annotations required: cannot resolve `<_ as std::ops::Try>::Ok == _`
--> src/main.rs:4:5
|
4 | vec![Ok(2)].into_iter().collect()?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
The solution is to do .collect::<Result<Vec<_>,_>>()?
(playground)
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Category: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint; hard to understand for new users.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Relevant to the compiler team, which will review and decide on the PR/issue.