Skip to content

Commit

Permalink
Auto merge of #9654 - ehuss:windows-env-upper-check, r=alexcrichton
Browse files Browse the repository at this point in the history
Update Windows env uppercase key check.

This is the followup for #9646. Rust now correctly spawns processes with preserved casing on nightly on Windows, so the exceptions here are no longer needed.
  • Loading branch information
bors committed Jul 12, 2021
2 parents a51667c + 652c5d9 commit 2517af4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
19 changes: 5 additions & 14 deletions src/cargo/util/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,11 @@ impl Config {
})
.collect();

let upper_case_env = if cfg!(windows) {
HashMap::new()
} else {
env.clone()
.into_iter()
.map(|(k, _)| (k.to_uppercase().replace("-", "_"), k))
.collect()
};
let upper_case_env = env
.clone()
.into_iter()
.map(|(k, _)| (k.to_uppercase().replace("-", "_"), k))
.collect();

let cache_rustc_info = match env.get("CARGO_CACHE_RUSTC_INFO") {
Some(cache) => cache != "0",
Expand Down Expand Up @@ -696,12 +693,6 @@ impl Config {
}

fn check_environment_key_case_mismatch(&self, key: &ConfigKey) {
if cfg!(windows) {
// In the case of windows the check for case mismatch in keys can be skipped
// as windows already converts its environment keys into the desired format.
return;
}

if let Some(env_key) = self.upper_case_env.get(key.as_env_key()) {
let _ = self.shell().warn(format!(
"Environment variables are expected to use uppercase letters and underscores, \
Expand Down
7 changes: 5 additions & 2 deletions tests/testsuite/tool_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,12 @@ fn custom_linker_env() {
}

#[cargo_test]
// Temporarily disabled until https://github.com/rust-lang/rust/pull/85270 is in nightly.
#[cfg_attr(target_os = "windows", ignore)]
fn target_in_environment_contains_lower_case() {
if cfg!(windows) && !cargo_test_support::is_nightly() {
// Remove this check when 1.55 is stabilized.
// https://github.com/rust-lang/rust/pull/85270
return;
}
let p = project().file("src/main.rs", "fn main() {}").build();

let target = rustc_host();
Expand Down

0 comments on commit 2517af4

Please sign in to comment.