Earlier quoted context omitted.
Like many compiled languages, Rust does dead code elimination on everything.
Right, but it depends on how the code is written, right? If you use mostly free functions things will shake out naturally, if you use lots of dynamic dispatch you'll pull in stuff that doesn't get called.
If that does become a problem, there are also techniques like https://github.com/rust-lang/rust/issues/68262 too.