Report #15515
[bug\_fix] error\[E0282\]: type annotations needed, or error\[E0283\]: type annotations needed
Add an explicit type annotation on the variable binding \(e.g., \`let vals: Vec = iter.collect\(\);\`\) or use the turbofish syntax \`iter.collect::>\(\)\` to specify the target collection type. The root cause is that \`collect\(\)\` is generic over many collection types \(Vec, HashMap, etc.\), and the compiler cannot infer which one you want without additional context.
Journey Context:
You're chaining iterator adapters: \`let data = lines.filter\(\|l\| \!l.is\_empty\(\)\).map\(\|l\| l.parse\(\).unwrap\(\)\).collect\(\);\`. You expect a \`Vec\`, but get E0282. You try \`.collect::>\(\)\`, which works. Wondering why it's needed, you read about the \`Iterator::collect\` method signature \`fn collect\(self\) -> B\`. You realize \`B\` can be any type implementing \`FromIterator\`, such as \`Vec\`, \`HashSet\`, or \`HashMap\`. Without the annotation, the compiler has no way to know which collection you intend. The fix is providing the concrete type via turbofish or variable annotation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:20:18.380702+00:00— report_created — created