diff --git a/src/cargo/core/compiler/unit_dependencies.rs b/src/cargo/core/compiler/unit_dependencies.rs index 69ac801ff516..d95b4cc3ef2e 100644 --- a/src/cargo/core/compiler/unit_dependencies.rs +++ b/src/cargo/core/compiler/unit_dependencies.rs @@ -1103,7 +1103,7 @@ impl<'a, 'cfg> State<'a, 'cfg> { // If this is an optional dependency, and the new feature resolver // did not enable it, don't include it. if dep.is_optional() { - let features_for = unit_for.map_to_features_for(dep.artifact()); + let features_for = unit_for.map_to_features_for(None); if !self.is_dep_activated(pkg_id, features_for, dep.name_in_toml()) { return false; } diff --git a/tests/testsuite/artifact_dep.rs b/tests/testsuite/artifact_dep.rs index db1a15beefdd..b94e82fcfe33 100644 --- a/tests/testsuite/artifact_dep.rs +++ b/tests/testsuite/artifact_dep.rs @@ -2345,7 +2345,6 @@ fn calc_bin_artifact_fingerprint() { #[cargo_test] fn with_target_and_optional() { - // This is a incorrect behaviour got to be fixed. // See rust-lang/cargo#10526 if cross_compile::disabled() { return; @@ -2386,11 +2385,14 @@ fn with_target_and_optional() { p.cargo("check -Z bindeps -F d1 -v") .masquerade_as_nightly_cargo(&["bindeps"]) - .with_stderr_contains( + .with_stderr( "\ -[ERROR] environment variable `CARGO_BIN_FILE_D1` not defined +[COMPILING] d1 v0.0.1 [..] +[RUNNING] `rustc --crate-name d1 [..]--crate-type bin[..] +[CHECKING] foo v0.0.1 [..] +[RUNNING] `rustc --crate-name foo [..]--cfg[..]d1[..] +[FINISHED] dev [..] ", ) - .with_status(101) .run(); }