diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-03-21 20:22:38 +0100 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2021-03-21 20:22:38 +0100 |
| commit | 7b71719faf5ba6a230d097fddb288f79ccc570f1 (patch) | |
| tree | 73e747cd70df4cf394414d1894096d1fd759667a /library/std/src/sys/unix/process/process_unix.rs | |
| parent | 96783625a0a2906d70690a5d76f83b1ccc028434 (diff) | |
| download | rust-7b71719faf5ba6a230d097fddb288f79ccc570f1.tar.gz rust-7b71719faf5ba6a230d097fddb288f79ccc570f1.zip | |
Use io::Error::new_const everywhere to avoid allocations.
Diffstat (limited to 'library/std/src/sys/unix/process/process_unix.rs')
| -rw-r--r-- | library/std/src/sys/unix/process/process_unix.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 2eb64a99e59..9cc20ee224c 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -28,7 +28,10 @@ impl Command { let envp = self.capture_env(); if self.saw_nul() { - return Err(io::Error::new(ErrorKind::InvalidInput, "nul byte found in provided data")); + return Err(io::Error::new_const( + ErrorKind::InvalidInput, + &"nul byte found in provided data", + )); } let (ours, theirs) = self.setup_io(default, needs_stdin)?; @@ -118,7 +121,10 @@ impl Command { let envp = self.capture_env(); if self.saw_nul() { - return io::Error::new(ErrorKind::InvalidInput, "nul byte found in provided data"); + return io::Error::new_const( + ErrorKind::InvalidInput, + &"nul byte found in provided data", + ); } match self.setup_io(default, true) { @@ -442,9 +448,9 @@ impl Process { // and used for another process, and we probably shouldn't be killing // random processes, so just return an error. if self.status.is_some() { - Err(Error::new( + Err(Error::new_const( ErrorKind::InvalidInput, - "invalid argument: can't kill an exited process", + &"invalid argument: can't kill an exited process", )) } else { cvt(unsafe { libc::kill(self.pid, libc::SIGKILL) }).map(drop) |
