Casting a raw pointer requires size at compile time

⚓ Rust    📅 2026-01-23    👤 surdeus    👁️ 1      

surdeus

Hello,

I came through something strange while using a raw pointer. If I write:

some_pointer.cast<dyn SomeUnsizedTrait>

I get the following error:

error[E0277]: the size for values of type `dyn SomeUnsizedTrait` cannot be known at compilation 
time

Why does it need to know the size at compile time ? Isn't the "dynamically allocated" part of a pointer is not to be required to know the size of the element it points to at compile time ?

Thank you very much in advance for any help

1 post - 1 participant

Read full topic

🏷️ Rust_feed