Skip to content

Commit 1ae5dd8

Browse files
committed
Convert the crate to edition 2018
1 parent 84e66d7 commit 1ae5dd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+274
-397
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[package]
22
name = "nix"
33
description = "Rust friendly bindings to *nix APIs"
4+
edition = "2018"
45
version = "0.17.0"
56
authors = ["The nix-rust Project Developers"]
67
repository = "https://github.com/nix-rust/nix"

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,13 @@ Tier 3:
8888

8989
`nix` requires Rust 1.36.0 or newer.
9090

91-
To use `nix`, first add this to your `Cargo.toml`:
91+
To use `nix`, add this to your `Cargo.toml`:
9292

9393
```toml
9494
[dependencies]
9595
nix = "0.17.0"
9696
```
9797

98-
Then, add this to your crate root:
99-
100-
```rust,ignore
101-
extern crate nix;
102-
```
103-
10498
## Contributing
10599

106100
Contributions are very welcome. Please See [CONTRIBUTING](CONTRIBUTING.md) for

build.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#[cfg(target_os = "dragonfly")]
2-
extern crate cc;
3-
41
#[cfg(target_os = "dragonfly")]
52
fn main() {
63
cc::Build::new()

src/dir.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
use {Error, NixPath, Result};
2-
use errno::Errno;
3-
use fcntl::{self, OFlag};
4-
use libc;
1+
use crate::{Error, NixPath, Result};
2+
use crate::errno::Errno;
3+
use crate::fcntl::{self, OFlag};
54
use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd};
65
use std::ptr;
76
use std::ffi;
8-
use sys;
7+
use crate::sys;
98

109
#[cfg(target_os = "linux")]
1110
use libc::{dirent64 as dirent, readdir64_r as readdir_r};

src/env.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use {Error, Result};
1+
use cfg_if::cfg_if;
2+
use crate::{Error, Result};
23

34
/// Clear the environment of all name-value pairs.
45
///

src/errno.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
use cfg_if::cfg_if;
12
#[cfg(not(target_os = "dragonfly"))]
2-
use libc;
33
use libc::{c_int, c_void};
44
use std::{fmt, io, error};
5-
use {Error, Result};
5+
use crate::{Error, Result};
66

77
pub use self::consts::*;
88

@@ -584,8 +584,6 @@ fn desc(errno: Errno) -> &'static str {
584584

585585
#[cfg(any(target_os = "linux", target_os = "android"))]
586586
mod consts {
587-
use libc;
588-
589587
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
590588
#[repr(i32)]
591589
pub enum Errno {
@@ -873,8 +871,6 @@ mod consts {
873871

874872
#[cfg(any(target_os = "macos", target_os = "ios"))]
875873
mod consts {
876-
use libc;
877-
878874
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
879875
#[repr(i32)]
880876
pub enum Errno {
@@ -1110,8 +1106,6 @@ mod consts {
11101106

11111107
#[cfg(target_os = "freebsd")]
11121108
mod consts {
1113-
use libc;
1114-
11151109
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
11161110
#[repr(i32)]
11171111
pub enum Errno {
@@ -1328,8 +1322,6 @@ mod consts {
13281322

13291323
#[cfg(target_os = "dragonfly")]
13301324
mod consts {
1331-
use libc;
1332-
13331325
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
13341326
#[repr(i32)]
13351327
pub enum Errno {
@@ -1543,8 +1535,6 @@ mod consts {
15431535

15441536
#[cfg(target_os = "openbsd")]
15451537
mod consts {
1546-
use libc;
1547-
15481538
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
15491539
#[repr(i32)]
15501540
pub enum Errno {
@@ -1757,8 +1747,6 @@ mod consts {
17571747

17581748
#[cfg(target_os = "netbsd")]
17591749
mod consts {
1760-
use libc;
1761-
17621750
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
17631751
#[repr(i32)]
17641752
pub enum Errno {
@@ -1973,8 +1961,6 @@ mod consts {
19731961

19741962
#[cfg(target_os = "redox")]
19751963
mod consts {
1976-
use libc;
1977-
19781964
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
19791965
#[repr(i32)]
19801966
pub enum Errno {

src/fcntl.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
use errno::Errno;
1+
use crate::errno::Errno;
22
use libc::{self, c_char, c_int, c_uint, size_t, ssize_t};
33
use std::ffi::OsString;
44
#[cfg(not(target_os = "redox"))]
55
use std::os::raw;
66
use std::os::unix::ffi::OsStringExt;
77
use std::os::unix::io::RawFd;
8-
use sys::stat::Mode;
9-
use {NixPath, Result};
8+
use crate::sys::stat::Mode;
9+
use crate::{NixPath, Result};
1010

1111
#[cfg(any(target_os = "android", target_os = "linux"))]
1212
use std::ptr; // For splice and copy_file_range
1313
#[cfg(any(target_os = "android", target_os = "linux"))]
14-
use sys::uio::IoVec; // For vmsplice
14+
use crate::sys::uio::IoVec; // For vmsplice
1515

1616
#[cfg(any(
1717
target_os = "linux",
@@ -586,10 +586,10 @@ pub fn fallocate(
586586
target_env = "freebsd"
587587
))]
588588
mod posix_fadvise {
589-
use errno::Errno;
589+
use crate::errno::Errno;
590590
use libc;
591591
use std::os::unix::io::RawFd;
592-
use Result;
592+
use crate::Result;
593593

594594
libc_enum! {
595595
#[repr(i32)]

src/features.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pub use self::os::*;
33

44
#[cfg(any(target_os = "linux", target_os = "android"))]
55
mod os {
6-
use sys::utsname::uname;
6+
use crate::sys::utsname::uname;
77

88
// Features:
99
// * atomic cloexec on socket: 2.6.27

src/ifaddrs.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
//! Uses the Linux and/or BSD specific function `getifaddrs` to query the list
44
//! of interfaces and their associated addresses.
55
6+
use cfg_if::cfg_if;
67
use std::ffi;
78
use std::iter::Iterator;
89
use std::mem;
910
use std::option::Option;
1011

11-
use libc;
12-
13-
use {Result, Errno};
14-
use sys::socket::SockAddr;
15-
use net::if_::*;
12+
use crate::{Result, Errno};
13+
use crate::sys::socket::SockAddr;
14+
use crate::net::if_::*;
1615

1716
/// Describes a single address for an interface as returned by `getifaddrs`.
1817
#[derive(Clone, Debug, Eq, Hash, PartialEq)]

src/kmod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use libc;
66
use std::ffi::CStr;
77
use std::os::unix::io::AsRawFd;
88

9-
use errno::Errno;
10-
use Result;
9+
use crate::errno::Errno;
10+
use crate::Result;
1111

1212
/// Loads a kernel module from a buffer.
1313
///

src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,8 @@
1515
#![deny(missing_copy_implementations)]
1616
#![deny(missing_debug_implementations)]
1717

18-
// External crates
19-
#[macro_use]
20-
extern crate bitflags;
21-
#[macro_use]
22-
extern crate cfg_if;
23-
2418
// Re-exported external crates
25-
pub extern crate libc;
19+
pub use libc;
2620

2721
// Private internal modules
2822
#[macro_use] mod macros;

src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ macro_rules! libc_bitflags {
4848
)+
4949
}
5050
) => {
51-
bitflags! {
51+
::bitflags::bitflags! {
5252
$(#[$outer])*
5353
pub struct $BitFlags: $T {
5454
$(

src/mount.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use libc::{self, c_ulong, c_int};
2-
use {Result, NixPath};
3-
use errno::Errno;
2+
use crate::{Result, NixPath};
3+
use crate::errno::Errno;
44

55
libc_bitflags!(
66
pub struct MsFlags: c_ulong {

src/mqueue.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
//!
33
//! [Further reading and details on the C API](http://man7.org/linux/man-pages/man7/mq_overview.7.html)
44
5-
use Result;
6-
use errno::Errno;
5+
use crate::Result;
6+
use crate::errno::Errno;
77

88
use libc::{self, c_char, c_long, mqd_t, size_t};
99
use std::ffi::CString;
10-
use sys::stat::Mode;
10+
use crate::sys::stat::Mode;
1111
use std::mem;
1212

1313
libc_bitflags!{

src/net/if_.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
//! Uses Linux and/or POSIX functions to resolve interface names like "eth0"
44
//! or "socan1" into device numbers.
55
6-
use libc;
76
use libc::c_uint;
8-
use {Result, Error, NixPath};
7+
use crate::{Result, Error, NixPath};
98

109
/// Resolve an interface into a interface number.
1110
pub fn if_nametoindex<P: ?Sized + NixPath>(name: &P) -> Result<c_uint> {

src/poll.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
//! Wait for events to trigger on specific file descriptors
22
#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))]
3-
use sys::time::TimeSpec;
3+
use crate::sys::time::TimeSpec;
44
#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))]
5-
use sys::signal::SigSet;
5+
use crate::sys::signal::SigSet;
66
use std::os::unix::io::RawFd;
77

8-
use libc;
9-
use Result;
10-
use errno::Errno;
8+
use crate::Result;
9+
use crate::errno::Errno;
1110

1211
/// This is a wrapper around `libc::pollfd`.
1312
///

src/pty.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Create master and slave virtual pseudo-terminals (PTYs)
22
3-
use libc;
4-
53
pub use libc::pid_t as SessionId;
64
pub use libc::winsize as Winsize;
75

@@ -10,10 +8,10 @@ use std::io;
108
use std::mem;
119
use std::os::unix::prelude::*;
1210

13-
use sys::termios::Termios;
14-
use unistd::ForkResult;
15-
use {Result, Error, fcntl};
16-
use errno::Errno;
11+
use crate::sys::termios::Termios;
12+
use crate::unistd::{self, ForkResult, Pid};
13+
use crate::{Result, Error, fcntl};
14+
use crate::errno::Errno;
1715

1816
/// Representation of a master/slave pty pair
1917
///
@@ -71,7 +69,7 @@ impl Drop for PtyMaster {
7169
// invalid file descriptor. That frequently indicates a double-close
7270
// condition, which can cause confusing errors for future I/O
7371
// operations.
74-
let e = ::unistd::close(self.0);
72+
let e = unistd::close(self.0);
7573
if e == Err(Error::Sys(Errno::EBADF)) {
7674
panic!("Closing an invalid file descriptor!");
7775
};
@@ -80,13 +78,13 @@ impl Drop for PtyMaster {
8078

8179
impl io::Read for PtyMaster {
8280
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
83-
::unistd::read(self.0, buf).map_err(|e| e.as_errno().unwrap().into())
81+
unistd::read(self.0, buf).map_err(|e| e.as_errno().unwrap().into())
8482
}
8583
}
8684

8785
impl io::Write for PtyMaster {
8886
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
89-
::unistd::write(self.0, buf).map_err(|e| e.as_errno().unwrap().into())
87+
unistd::write(self.0, buf).map_err(|e| e.as_errno().unwrap().into())
9088
}
9189
fn flush(&mut self) -> io::Result<()> {
9290
Ok(())
@@ -309,8 +307,6 @@ pub fn forkpty<'a, 'b, T: Into<Option<&'a Winsize>>, U: Into<Option<&'b Termios>
309307
termios: U,
310308
) -> Result<ForkptyResult> {
311309
use std::ptr;
312-
use unistd::Pid;
313-
use unistd::ForkResult::*;
314310

315311
let mut master = mem::MaybeUninit::<libc::c_int>::uninit();
316312

@@ -332,8 +328,8 @@ pub fn forkpty<'a, 'b, T: Into<Option<&'a Winsize>>, U: Into<Option<&'b Termios>
332328
};
333329

334330
let fork_result = Errno::result(res).map(|res| match res {
335-
0 => Child,
336-
res => Parent { child: Pid::from_raw(res) },
331+
0 => ForkResult::Child,
332+
res => ForkResult::Parent { child: Pid::from_raw(res) },
337333
})?;
338334

339335
unsafe {

src/sched.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
use libc;
2-
use {Errno, Result};
1+
use crate::{Errno, Result};
32

43
#[cfg(any(target_os = "android", target_os = "linux"))]
54
pub use self::sched_linux_like::*;
65

76
#[cfg(any(target_os = "android", target_os = "linux"))]
87
mod sched_linux_like {
9-
use errno::Errno;
8+
use crate::errno::Errno;
109
use libc::{self, c_int, c_void};
1110
use std::mem;
1211
use std::option::Option;
1312
use std::os::unix::io::RawFd;
14-
use unistd::Pid;
15-
use {Error, Result};
13+
use crate::unistd::Pid;
14+
use crate::{Error, Result};
1615

1716
// For some functions taking with a parameter of type CloneFlags,
1817
// only a subset of these flags have an effect.

0 commit comments

Comments
 (0)