Skip to content

Commit d3fef37

Browse files
bors[bot]oherrala
andauthored
Merge #1239
1239: Replace void crate with Rust standard lib Infallible type r=asomers a=oherrala [`std::convert::Infallible`](https://doc.rust-lang.org/stable/std/convert/enum.Infallible.html) has been available since Rust 1.34 and nix currently targets Rust 1.36 or later so this should not cause problems. Fixes #1238 Co-authored-by: Ossi Herrala <[email protected]>
2 parents 2f78ec2 + 71aa2a6 commit d3fef37

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
3636
(#[1198](https://github.com/nix-rust/nix/pull/1198))
3737
- On Linux, `ptrace::write` is now an `unsafe` function. Caveat programmer.
3838
(#[1245](https://github.com/nix-rust/nix/pull/1245))
39+
- `execv`, `execve`, `execvp` and `execveat` in `::nix::unistd` and `reboot` in
40+
`::nix::sys::reboot` now return `Result<Infallible>` instead of `Result<Void>` (#[1239](https://github.com/nix-rust/nix/pull/1239))
3941

4042
### Fixed
4143

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ exclude = [
1919
libc = { git = "https://github.com/rust-lang/libc/", features = [ "extra_traits" ] }
2020
bitflags = "1.1"
2121
cfg-if = "0.1.10"
22-
void = "1.0.2"
2322

2423
[target.'cfg(target_os = "dragonfly")'.build-dependencies]
2524
cc = "1"

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
extern crate bitflags;
2121
#[macro_use]
2222
extern crate cfg_if;
23-
extern crate void;
2423

2524
// Re-exported external crates
2625
pub extern crate libc;

src/sys/reboot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use {Error, Result};
44
use errno::Errno;
55
use libc;
6-
use void::Void;
6+
use std::convert::Infallible;
77
use std::mem::drop;
88

99
libc_enum! {
@@ -22,7 +22,7 @@ libc_enum! {
2222
}
2323
}
2424

25-
pub fn reboot(how: RebootMode) -> Result<Void> {
25+
pub fn reboot(how: RebootMode) -> Result<Infallible> {
2626
unsafe {
2727
libc::reboot(how as libc::c_int)
2828
};

src/unistd.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ use fcntl::FcntlArg::F_SETFD;
77
use libc::{self, c_char, c_void, c_int, c_long, c_uint, size_t, pid_t, off_t,
88
uid_t, gid_t, mode_t, PATH_MAX};
99
use std::{fmt, mem, ptr};
10+
use std::convert::Infallible;
1011
use std::ffi::{CString, CStr, OsString, OsStr};
1112
use std::os::unix::ffi::{OsStringExt, OsStrExt};
1213
use std::os::unix::io::RawFd;
1314
use std::path::PathBuf;
14-
use void::Void;
1515
use sys::stat::Mode;
1616

1717
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -707,7 +707,7 @@ fn to_exec_array(args: &[&CStr]) -> Vec<*const c_char> {
707707
/// performs the same action but does not allow for customization of the
708708
/// environment for the new process.
709709
#[inline]
710-
pub fn execv(path: &CStr, argv: &[&CStr]) -> Result<Void> {
710+
pub fn execv(path: &CStr, argv: &[&CStr]) -> Result<Infallible> {
711711
let args_p = to_exec_array(argv);
712712

713713
unsafe {
@@ -731,7 +731,7 @@ pub fn execv(path: &CStr, argv: &[&CStr]) -> Result<Void> {
731731
/// in the `args` list is an argument to the new process. Each element in the
732732
/// `env` list should be a string in the form "key=value".
733733
#[inline]
734-
pub fn execve(path: &CStr, args: &[&CStr], env: &[&CStr]) -> Result<Void> {
734+
pub fn execve(path: &CStr, args: &[&CStr], env: &[&CStr]) -> Result<Infallible> {
735735
let args_p = to_exec_array(args);
736736
let env_p = to_exec_array(env);
737737

@@ -752,7 +752,7 @@ pub fn execve(path: &CStr, args: &[&CStr], env: &[&CStr]) -> Result<Void> {
752752
/// would not work if "bash" was specified for the path argument, but `execvp`
753753
/// would assuming that a bash executable was on the system `PATH`.
754754
#[inline]
755-
pub fn execvp(filename: &CStr, args: &[&CStr]) -> Result<Void> {
755+
pub fn execvp(filename: &CStr, args: &[&CStr]) -> Result<Infallible> {
756756
let args_p = to_exec_array(args);
757757

758758
unsafe {
@@ -772,7 +772,7 @@ pub fn execvp(filename: &CStr, args: &[&CStr]) -> Result<Void> {
772772
#[cfg(any(target_os = "haiku",
773773
target_os = "linux",
774774
target_os = "openbsd"))]
775-
pub fn execvpe(filename: &CStr, args: &[&CStr], env: &[&CStr]) -> Result<Void> {
775+
pub fn execvpe(filename: &CStr, args: &[&CStr], env: &[&CStr]) -> Result<Infallible> {
776776
let args_p = to_exec_array(args);
777777
let env_p = to_exec_array(env);
778778

@@ -800,7 +800,7 @@ pub fn execvpe(filename: &CStr, args: &[&CStr], env: &[&CStr]) -> Result<Void> {
800800
target_os = "linux",
801801
target_os = "freebsd"))]
802802
#[inline]
803-
pub fn fexecve(fd: RawFd, args: &[&CStr], env: &[&CStr]) -> Result<Void> {
803+
pub fn fexecve(fd: RawFd, args: &[&CStr], env: &[&CStr]) -> Result<Infallible> {
804804
let args_p = to_exec_array(args);
805805
let env_p = to_exec_array(env);
806806

@@ -824,7 +824,7 @@ pub fn fexecve(fd: RawFd, args: &[&CStr], env: &[&CStr]) -> Result<Void> {
824824
#[cfg(any(target_os = "android", target_os = "linux"))]
825825
#[inline]
826826
pub fn execveat(dirfd: RawFd, pathname: &CStr, args: &[&CStr],
827-
env: &[&CStr], flags: super::fcntl::AtFlags) -> Result<Void> {
827+
env: &[&CStr], flags: super::fcntl::AtFlags) -> Result<Infallible> {
828828
let args_p = to_exec_array(args);
829829
let env_p = to_exec_array(env);
830830

0 commit comments

Comments
 (0)