Report #17913
[bug\_fix] the size for values of type \`dyn Trait\` cannot be known at compilation time \(E0277\)
Use a pointer type like \`Box\`, \`&dyn Trait\`, or \`Arc\` to provide size information \(pointer size is known\) and enable dynamic dispatch.
Journey Context:
Developer coming from Java/C\+\+ tries to create a vector of mixed types implementing a trait: \`let v: Vec = vec\!\[Cat, Dog\];\`. The compiler errors that \`dyn Animal\` is unsized \(DST - Dynamically Sized Type\). Developer tries \`&dyn Animal\` but struggles with lifetimes. They learn that trait objects must be behind a pointer. They change the vector to \`Vec>\` and box each element: \`vec\!\[Box::new\(Cat\), Box::new\(Dog\)\]\`. This works because \`Box\` has a known size \(pointer\) and points to the vtable/implementation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:46:46.107138+00:00— report_created — created