about summary refs log tree commit diff
path: root/library/std/src/sys_common/process.rs
diff options
context:
space:
mode:
authorChris Denton <christophersdenton@gmail.com>2021-08-08 14:23:08 +0100
committerChris Denton <christophersdenton@gmail.com>2021-08-08 16:03:39 +0100
commit419902e413ddd62673f8e54c71e5164d862aee08 (patch)
tree60623676a64528f2c1954e5fd18924f4216d9c77 /library/std/src/sys_common/process.rs
parente8c25f266349a68faa8c4fb68f5c1d5e4512790f (diff)
downloadrust-419902e413ddd62673f8e54c71e5164d862aee08.tar.gz
rust-419902e413ddd62673f8e54c71e5164d862aee08.zip
Fix Windows Command::env("PATH")
Diffstat (limited to 'library/std/src/sys_common/process.rs')
-rw-r--r--library/std/src/sys_common/process.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/library/std/src/sys_common/process.rs b/library/std/src/sys_common/process.rs
index fe89b11043c..38007d5c414 100644
--- a/library/std/src/sys_common/process.rs
+++ b/library/std/src/sys_common/process.rs
@@ -65,16 +65,18 @@ impl CommandEnv {
 
     // The following functions build up changes
     pub fn set(&mut self, key: &OsStr, value: &OsStr) {
+        let key = EnvKey::from(key);
         self.maybe_saw_path(&key);
-        self.vars.insert(key.to_owned().into(), Some(value.to_owned()));
+        self.vars.insert(key, Some(value.to_owned()));
     }
 
     pub fn remove(&mut self, key: &OsStr) {
+        let key = EnvKey::from(key);
         self.maybe_saw_path(&key);
         if self.clear {
-            self.vars.remove(key);
+            self.vars.remove(&key);
         } else {
-            self.vars.insert(key.to_owned().into(), None);
+            self.vars.insert(key, None);
         }
     }
 
@@ -87,7 +89,7 @@ impl CommandEnv {
         self.saw_path || self.clear
     }
 
-    fn maybe_saw_path(&mut self, key: &OsStr) {
+    fn maybe_saw_path(&mut self, key: &EnvKey) {
         if !self.saw_path && key == "PATH" {
             self.saw_path = true;
         }