Why does rust need to know the size of types at compile time?

Any time you want to copy (or move) it, for example. This includes returning something by value.