Does crates.io compile new crates before registering?

The cargo publish command does compile your package before uploading (it calls this "verification"), but you can skip that if you want. The crates.io server does not; the server's checks are about things like that its dependencies are valid.

As you observe, if the server did compile them, that wouldn't be sure the code works as intended; but also, it can't even do that — it's entirely valid to publish packages which only compile for Windows because they use Windows system calls, or only compile for ARM architectures because they use inline assembly, or only compile for a microcontroller architecture that can't even run rustc.

In general, there are not and cannot be any kind of machine-enforced guarantee that a package on crates.io is actually useful.

2 Likes