Compiler Explorer's Rust crates are prebuilt rlibs fetched from Conan,
and setupBuildEnvironment already unpacks them into the project before
the sandboxed build -- they just never reached rustc. cargo cannot
resolve them itself, since it wants sources from a registry and there is
no network on a build node, so the driver now passes them straight
through as --extern via CARGO_ENCODED_RUSTFLAGS. `use rand::Rng;` works
with nothing declared in Cargo.toml, which is the same mechanism the
single-file Rust path has always used.
The encoded form is used rather than RUSTFLAGS because it is
separator-delimited, so paths and flags containing spaces survive.
A [dependencies] entry still cannot work, and cargo's message for it --
"no matching package named ..., location searched: crates.io index" --
gives no hint that the Libraries pane is the answer. Build steps gained
an optional explainFailure hook for exactly this: turning a build tool's
own diagnostics into something actionable in Compiler Explorer's terms.
The Cargo example manifest says the same thing up front.
Verified in the browser and by API: selecting rand 0.8.5 downloads the
package, builds, and runs, and declaring it in [dependencies] instead
now fails with an explanation rather than a bare resolution error.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>