Report #44904
[bug\_fix] type annotations needed for \`collect\(\)\` \(E0282/E0283\)
Explicitly specify the target collection type using the turbofish syntax \`collect::>\(\)\` or by annotating the variable binding \`let v: Vec = iter.collect\(\);\`.
Journey Context:
A developer is processing an iterator chain: \`let nums = \(0..10\).map\(\|x\| x \* 2\).filter\(\|x\| x > 5\).collect\(\);\`. They expect \`nums\` to be a \`Vec\`, but the compiler emits E0282 stating it cannot infer the type of the type parameter \`B\` declared on the method \`collect\`. The developer is confused because the element type \`i32\` seems obvious from the map closure. They try \`collect::>\(\)\` and it works. They realize that \`collect\(\)\` is generic over any collection type implementing \`FromIterator\` \(Vec, HashSet, LinkedList, etc.\), and without a hint, the compiler has no unique type to resolve to. They learn to use the turbofish \`::<>\` or explicit variable types to guide inference at the end of iterator chains.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T05:50:19.728207+00:00— report_created — created