Skip to content

Commit

Permalink
Auto merge of #92396 - xfix:remove-commandenv-apply, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Remove CommandEnv::apply

It's not being used and uses unsound set_var and remove_var functions. This is an internal function that isn't exported (even with `process_internals` feature), so this shouldn't break anything.

Also see #92365. Note that this isn't the only use of those methods in standard library, so that particular pull request will need more changes than just this to work (in particular, `test_capture_env_at_spawn` is using `set_var` and `remove_var`).
  • Loading branch information
bors committed Jan 1, 2022
2 parents c145692 + 14fc9dc commit dd3ac41
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions library/std/src/sys_common/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,6 @@ impl CommandEnv {
result
}

// Apply these changes directly to the current environment
pub fn apply(&self) {
if self.clear {
for (k, _) in env::vars_os() {
env::remove_var(k);
}
}
for (key, maybe_val) in self.vars.iter() {
if let Some(ref val) = maybe_val {
env::set_var(key, val);
} else {
env::remove_var(key);
}
}
}

pub fn is_unchanged(&self) -> bool {
!self.clear && self.vars.is_empty()
}
Expand Down

0 comments on commit dd3ac41

Please sign in to comment.