From 4592af4a2ab6a0bf48a75b33ce8843de8adf96e6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 6 Sep 2019 15:36:43 -0700 Subject: [PATCH] Don't resolve std's optional dependencies Use the `set_require_optional_deps(false)` escape hatch to avoid resolving optional dependencies for libstd. While it doesn't really matter a huge amount either way there's no need for us to generate resolution nodes for things like `rand` just to throw them away because they're never used. Closes rust-lang/wg-cargo-std-aware#37 --- src/cargo/core/compiler/standard_lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cargo/core/compiler/standard_lib.rs b/src/cargo/core/compiler/standard_lib.rs index 551f67c01b7..fb58363f0d5 100644 --- a/src/cargo/core/compiler/standard_lib.rs +++ b/src/cargo/core/compiler/standard_lib.rs @@ -80,10 +80,13 @@ pub fn resolve_std<'cfg>( // now. Perhaps in the future features will be decoupled from the resolver // and it will be easier to control feature selection. let current_manifest = src_path.join("src/libtest/Cargo.toml"); - // TODO: Consider setting require_option_deps false? // TODO: Consider doing something to enforce --locked? Or to prevent the // lock file from being written, such as setting ephemeral. - let std_ws = Workspace::new_virtual(src_path, current_manifest, virtual_manifest, config)?; + let mut std_ws = Workspace::new_virtual(src_path, current_manifest, virtual_manifest, config)?; + // Don't require optional dependencies in this workspace, aka std's own + // `[dev-dependencies]`. No need for us to generate a `Resolve` which has + // those included because we'll never use them anyway. + std_ws.set_require_optional_deps(false); // `test` is not in the default set because it is optional, but it needs // to be part of the resolve in case we do need it. let mut spec_pkgs = Vec::from(crates);