That doesn’t make sense, you don’t link against the entire rust stdlib, you compile directly against its source. You don’t get more than what you call.
You don’t compile the Rust standard library from source, you link against a pre-built one. There is an unstable option to compile the standard library from source.
That said, you’re right that “to keep binary size down” isn’t why the standard library is small. Heck, that you don’t compile from source means sometimes binaries are larger than they have to be, even with LTO! It is largely because anything that’s there has to be supported exactly as is forever, interface wise, and for many things, we did not have the confidence on what the right interface would be. Furthermore, it’s harder to maintain the standard library than it is a package out of tree for a variety of reasons.
Thank you for the correction. My confusion comes from being able to command-click on standard library types and methods, and being taken to their implementation, not just a declaration. I realize these aren't really concepts in Rust the same way they are in e.g. C/C++, but I figured if the source is present, the compiler is smart enough to not be over-compiling unused symbols.
Yeah, it's all good. Rustup will also distribute the source:
~> rustup component list | rg src
rust-src (installed)
But this is so that that workflow works well, not because the compiler actually uses it during the build.
> the compiler is smart enough to not be over-compiling unused symbols.
This is true even without the source, mind you, but the devil is just in the details. Stuff like the panic and/or formatting machinery is known to creep in even if you don't think you're using it, because some edge case might. This only truly matters for embedded and similar, but it's still a thing.