diff --git a/src/cargo/core/compiler/artifact.rs b/src/cargo/core/compiler/artifact.rs index d6b9fc105b3..e03ac82d9ac 100644 --- a/src/cargo/core/compiler/artifact.rs +++ b/src/cargo/core/compiler/artifact.rs @@ -66,33 +66,13 @@ pub fn get_env( dep_name_upper, unit_dep.unit.target.name() ); - - // In older releases, lib-targets defaulted to the name of the package. Newer releases - // use the same name as default, but with dashes replaced. Hence, if the name of the - // target was inferred by Cargo, we also set the env-var with the unconverted name for - // backwards compatibility. - let need_compat = unit_dep.unit.target.is_lib() && unit_dep.unit.target.name_inferred(); - if need_compat { - let var_compat = format!( - "CARGO_{}_FILE_{}_{}", - artifact_type_upper, - dep_name_upper, - unit_dep.unit.pkg.name(), - ); - if var_compat != var_file { - env.insert(var_compat, artifact_path.to_owned().into()); - } - } - env.insert(var_file, artifact_path.to_owned().into()); // If the name of the target matches the name of the dependency, we strip the // repetition and provide the simpler env-var as well. // For backwards-compatibility of inferred names, we compare against the name of the // package as well, since that used to be the default for library targets. - if unit_dep.unit.target.name() == dep_name.as_str() - || (need_compat && unit_dep.unit.pkg.name() == dep_name.as_str()) - { + if unit_dep.unit.target.name() == dep_name.as_str() { let var = format!("CARGO_{}_FILE_{}", artifact_type_upper, dep_name_upper,); env.insert(var, artifact_path.to_owned().into()); } diff --git a/tests/testsuite/artifact_dep.rs b/tests/testsuite/artifact_dep.rs index b5100a6567d..db28f921e59 100644 --- a/tests/testsuite/artifact_dep.rs +++ b/tests/testsuite/artifact_dep.rs @@ -858,11 +858,7 @@ fn lib_with_selected_dashed_bin_artifact_and_lib_true() { env!("CARGO_BIN_DIR_BAR_BAZ"); let _b = include_bytes!(env!("CARGO_BIN_FILE_BAR_BAZ_baz-suffix")); - let _b = include_bytes!(env!("CARGO_STATICLIB_FILE_BAR_BAZ")); - let _b = include_bytes!(env!("CARGO_STATICLIB_FILE_BAR_BAZ_bar-baz")); let _b = include_bytes!(env!("CARGO_STATICLIB_FILE_BAR_BAZ_bar_baz")); - let _b = include_bytes!(env!("CARGO_CDYLIB_FILE_BAR_BAZ")); - let _b = include_bytes!(env!("CARGO_CDYLIB_FILE_BAR_BAZ_bar-baz")); let _b = include_bytes!(env!("CARGO_CDYLIB_FILE_BAR_BAZ_bar_baz")); } "#,