Skip to content

Commit

Permalink
Remove ref_env
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo authored and sylvestre committed Jun 16, 2024
1 parent f1debd2 commit 78f3a32
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::dist::pkg;
#[cfg(feature = "dist-client")]
use crate::lru_disk_cache;
use crate::mock_command::{exit_status, CommandChild, CommandCreatorSync, RunCommand};
use crate::util::{fmt_duration_as_secs, ref_env, run_input_output};
use crate::util::{fmt_duration_as_secs, run_input_output};
use crate::{counted_array, dist};
use async_trait::async_trait;
use filetime::FileTime;
Expand Down Expand Up @@ -1100,7 +1100,7 @@ where
child.arg(&rustc_executable);
}

child.env_clear().envs(ref_env(env)).args(&["-vV"]);
child.env_clear().envs(env.to_vec()).args(&["-vV"]);

let rustc_vv = run_input_output(child, None).await.map(|output| {
if let Ok(stdout) = String::from_utf8(output.stdout.clone()) {
Expand Down
18 changes: 9 additions & 9 deletions src/compiler/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::dist::pkg;
use crate::lru_disk_cache::{LruCache, Meter};
use crate::mock_command::{CommandCreatorSync, RunCommand};
use crate::util::{fmt_duration_as_secs, hash_all, hash_all_archives, run_input_output, Digest};
use crate::util::{ref_env, HashToDigest, OsStrExt};
use crate::util::{HashToDigest, OsStrExt};
use crate::{counted_array, dist};
use async_trait::async_trait;
use filetime::FileTime;
Expand Down Expand Up @@ -242,7 +242,7 @@ where
.arg("-o")
.arg(&dep_file)
.env_clear()
.envs(ref_env(env_vars))
.envs(env_vars.to_vec())
.current_dir(cwd);
trace!("[{}]: get dep-info: {:?}", crate_name, cmd);
// Output of command is in file under dep_file, so we ignore stdout&stderr
Expand Down Expand Up @@ -364,7 +364,7 @@ where
cmd.args(&arguments)
.args(&["--print", "file-names"])
.env_clear()
.envs(ref_env(env_vars))
.envs(env_vars.to_vec())
.current_dir(cwd);
if log_enabled!(Trace) {
trace!("get_compiler_outputs: {:?}", cmd);
Expand Down Expand Up @@ -406,7 +406,7 @@ impl Rust {
.stderr(process::Stdio::null())
.arg("--print=sysroot")
.env_clear()
.envs(ref_env(env_vars));
.envs(env_vars.to_vec());
let sysroot_and_libs = async move {
let output = run_input_output(cmd, None).await?;
//debug!("output.and_then: {}", output);
Expand Down Expand Up @@ -549,7 +549,7 @@ where
child
.current_dir(&cwd)
.env_clear()
.envs(ref_env(env))
.envs(env.to_vec())
.args(&["which", "rustc"]);

Box::pin(async move {
Expand Down Expand Up @@ -632,7 +632,7 @@ impl RustupProxy {

// verify rustc is proxy
let mut child = creator.new_command_sync(compiler_executable);
child.env_clear().envs(ref_env(env)).args(&["+stable"]);
child.env_clear().envs(env.to_vec()).args(&["+stable"]);
let state = run_input_output(child, None).await.map(move |output| {
if output.status.success() {
trace!("proxy: Found a compiler proxy managed by rustup");
Expand Down Expand Up @@ -695,7 +695,7 @@ impl RustupProxy {
Ok(ProxyPath::Candidate(proxy_executable)) => {
// verify the candidate is a rustup
let mut child = creator.new_command_sync(&proxy_executable);
child.env_clear().envs(ref_env(env)).args(&["--version"]);
child.env_clear().envs(env.to_vec()).args(&["--version"]);
let rustup_candidate_check = run_input_output(child, None).await?;

let stdout = String::from_utf8(rustup_candidate_check.stdout)
Expand Down Expand Up @@ -2305,7 +2305,7 @@ impl RlibDepReader {
.arg(&temp_rlib)
.arg("-")
.env_clear()
.envs(ref_env(env_vars));
.envs(env_vars.to_vec());

let process::Output {
status,
Expand Down Expand Up @@ -2377,7 +2377,7 @@ impl RlibDepReader {
cmd.args(["-Z", "ls"])
.arg(rlib)
.env_clear()
.envs(ref_env(env_vars))
.envs(env_vars.to_vec())
.env("RUSTC_BOOTSTRAP", "1"); // TODO: this is fairly naughty

let process::Output {
Expand Down
5 changes: 0 additions & 5 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,6 @@ impl<'a> Hasher for HashToDigest<'a> {
}
}

/// Turns a slice of environment var tuples into the type expected by Command::envs.
pub fn ref_env(env: &[(OsString, OsString)]) -> impl Iterator<Item = (&OsString, &OsString)> {
env.iter().map(|(k, v)| (k, v))
}

/// Pipe `cmd`'s stdio to `/dev/null`, unless a specific env var is set.
#[cfg(not(windows))]
pub fn daemonize() -> Result<()> {
Expand Down

0 comments on commit 78f3a32

Please sign in to comment.