Re:Cargo: predictable dependency management
by SimonSapin on Thursday May 05, 2016 @02:10PM
(#11638437)
Short answer: `extern crate foo;` doesn’t work if `foo` is an indirect dependency. So you cannot accidentally use something without declaring it in `Cargo.toml`.
Longer answer: when running rustc, Cargo passes individual `--extern bar=/path/to/bar.rlib` options for each direct dependency, not just a path to a directory with everything. You can see the exact command with `cargo build --verbose` or `cargo build -v`.
Re:Cargo: predictable dependency management
by tatterdemalion on Thursday May 05, 2016 @02:43PM
(#11638714)
As the sibling answer says, they are not visible.
However, crates can re-export symbols they have imported from their dependency, which couples their semver to that dependency's in a way that people have often not realized. This has been the source of some upgrade headaches so far, but its less of a problem than it has been with languages in my experience.
Re:Cargo: predictable dependency management
by keeperofdakeys on Thursday May 05, 2016 @06:08PM
(#11640019)
It's also relevant that rust can use multiple direct/indirect dependencies of different versions, due to the way that symbols are exported.
If the answer is that indirect dependencies are still visible, I'd be interested in knowing if rust-lang/cargo plan to change that, similar to JDK9's module system for re-export.