From c156af5a90e89291d4c540610549c3132d884661 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Tue, 2 Jul 2019 13:39:25 -0600 Subject: [PATCH 1/3] Fix warnings on Rust 1.37.0 * Replace obsolete range syntax "..." with inclusive range "..=" * Use dyn Trait syntax instead of Box * Raise MSRV to 1.27.0 (for dyn Trait syntax) * Raise MSRV to 1.31.0 (because of rand) tempfile pulls in rand, and rand pulls in fuchsia-cprng, which requires 1.31.0. Why rand pulls in fuchsia-cprng I don't know. It's specified as a target-specific dependency, but Cargo tries to build it anyway (only on Linux, not on FreeBSD or OSX). A bug in Cargo 1.27.0? --- .cirrus.yml | 2 +- .travis.yml | 50 ++++++++++++++++++++--------------------- CHANGELOG.md | 3 ++- README.md | 2 +- src/features.rs | 2 +- src/sched.rs | 4 ++-- src/sys/aio.rs | 24 ++++++++++---------- src/sys/socket/mod.rs | 2 +- test/sys/test_socket.rs | 23 +++++++++---------- 9 files changed, 56 insertions(+), 56 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index eca3d347c4..db1a90ada9 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -14,7 +14,7 @@ task: setup_script: - pkg install -y curl - curl https://sh.rustup.rs -sSf --output rustup.sh - - sh rustup.sh -y --default-toolchain 1.25.0 + - sh rustup.sh -y --default-toolchain 1.31.0 - $HOME/.cargo/bin/rustup target add i686-unknown-freebsd amd64_test_script: - . $HOME/.cargo/env diff --git a/.travis.yml b/.travis.yml index a667201a86..917105e6a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,71 +18,71 @@ matrix: # week. Additionally they're moved to the front of the line to get them in # the Travis OS X build queue first. - env: TARGET="aarch64-apple-ios;armv7-apple-ios;armv7s-apple-ios;i386-apple-ios;x86_64-apple-ios" DISABLE_TESTS=1 - rust: 1.25.0 + rust: 1.31.0 os: osx # Mac builds # These are also moved to be first because they wait in a long queue with # Travis - env: TARGET=i686-apple-darwin - rust: 1.25.0 + rust: 1.31.0 os: osx - env: TARGET=x86_64-apple-darwin - rust: 1.25.0 + rust: 1.31.0 os: osx # Android - env: TARGET=aarch64-linux-android DISABLE_TESTS=1 - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=arm-linux-androideabi DISABLE_TESTS=1 - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=armv7-linux-androideabi DISABLE_TESTS=1 - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=i686-linux-android DISABLE_TESTS=1 - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=x86_64-linux-android DISABLE_TESTS=1 - rust: 1.25.0 + rust: 1.31.0 # Linux - env: TARGET=aarch64-unknown-linux-gnu - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=arm-unknown-linux-gnueabi - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=arm-unknown-linux-musleabi DISABLE_TESTS=1 - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=armv7-unknown-linux-gnueabihf - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=i686-unknown-linux-gnu - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=i686-unknown-linux-musl - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=mips-unknown-linux-gnu - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=mips64-unknown-linux-gnuabi64 - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=mips64el-unknown-linux-gnuabi64 - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=mipsel-unknown-linux-gnu - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=powerpc-unknown-linux-gnu DISABLE_TESTS=1 - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=powerpc64-unknown-linux-gnu - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=powerpc64le-unknown-linux-gnu - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1 - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=x86_64-unknown-linux-gnu - rust: 1.25.0 + rust: 1.31.0 - env: TARGET=x86_64-unknown-linux-musl - rust: 1.25.0 + rust: 1.31.0 # *BSD # FreeBSD i686 and x86_64 use Cirrus instead of Travis # - env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1 # - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1 - env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1 - rust: 1.25.0 + rust: 1.31.0 # Make sure stable is always working too - env: TARGET=x86_64-unknown-linux-gnu diff --git a/CHANGELOG.md b/CHANGELOG.md index 777b4d98d9..863216b711 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,8 +19,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Changed - Support for `ifaddrs` now present when building for Android. ([#1077](https://github.com/nix-rust/nix/pull/1077)) -- Minimum supported Rust version is now 1.25.0 +- Minimum supported Rust version is now 1.31.0 ([#1035](https://github.com/nix-rust/nix/pull/1035)) + ([#1095](https://github.com/nix-rust/nix/pull/1095)) - Now functions `statfs()` and `fstatfs()` return result with `Statfs` wrapper ([#928](https://github.com/nix-rust/nix/pull/928)) diff --git a/README.md b/README.md index 41ee98a525..8d8fd72908 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Tier 2: ## Usage -`nix` requires Rust 1.25.0 or newer. +`nix` requires Rust 1.31.0 or newer. To use `nix`, first add this to your `Cargo.toml`: diff --git a/src/features.rs b/src/features.rs index 7797aa4641..76cdfd3a1a 100644 --- a/src/features.rs +++ b/src/features.rs @@ -39,7 +39,7 @@ mod os { b'.' | b'-' => { curr += 1; } - b'0'...b'9' => { + b'0'..=b'9' => { match curr { 0 => digit(&mut major, b), 1 => digit(&mut minor, b), diff --git a/src/sched.rs b/src/sched.rs index 064fc29dc9..67188c57ee 100644 --- a/src/sched.rs +++ b/src/sched.rs @@ -44,7 +44,7 @@ mod sched_linux_like { } } - pub type CloneCb<'a> = Box isize + 'a>; + pub type CloneCb<'a> = Box isize + 'a>; #[repr(C)] #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] @@ -113,7 +113,7 @@ mod sched_linux_like { let ptr_aligned = ptr.offset((ptr as usize % 16) as isize * -1); libc::clone( mem::transmute( - callback as extern "C" fn(*mut Box<::std::ops::FnMut() -> isize>) -> i32, + callback as extern "C" fn(*mut Box isize>) -> i32, ), ptr_aligned as *mut c_void, combined, diff --git a/src/sys/aio.rs b/src/sys/aio.rs index 40fa4e1517..9258a0657c 100644 --- a/src/sys/aio.rs +++ b/src/sys/aio.rs @@ -102,9 +102,9 @@ pub enum Buffer<'a> { /// Keeps a reference to a slice Phantom(PhantomData<&'a mut [u8]>), /// Generic thing that keeps a buffer from dropping - BoxedSlice(Box>), + BoxedSlice(Box>), /// Generic thing that keeps a mutable buffer from dropping - BoxedMutSlice(Box>), + BoxedMutSlice(Box>), } impl<'a> Debug for Buffer<'a> { @@ -116,14 +116,14 @@ impl<'a> Debug for Buffer<'a> { Buffer::None => write!(fmt, "None"), Buffer::Phantom(p) => p.fmt(fmt), Buffer::BoxedSlice(ref bs) => { - let borrowed : &Borrow<[u8]> = bs.borrow(); + let borrowed : &dyn Borrow<[u8]> = bs.borrow(); write!(fmt, "BoxedSlice({:?})", - borrowed as *const Borrow<[u8]>) + borrowed as *const dyn Borrow<[u8]>) }, Buffer::BoxedMutSlice(ref bms) => { - let borrowed : &BorrowMut<[u8]> = bms.borrow(); + let borrowed : &dyn BorrowMut<[u8]> = bms.borrow(); write!(fmt, "BoxedMutSlice({:?})", - borrowed as *const BorrowMut<[u8]>) + borrowed as *const dyn BorrowMut<[u8]>) } } } @@ -165,7 +165,7 @@ impl<'a> AioCb<'a> { /// /// It is an error to call this method while the `AioCb` is still in /// progress. - pub fn boxed_slice(&mut self) -> Option>> { + pub fn boxed_slice(&mut self) -> Option>> { assert!(!self.in_progress, "Can't remove the buffer from an AioCb that's still in-progress. Did you forget to call aio_return?"); if let Buffer::BoxedSlice(_) = self.buffer { let mut oldbuffer = Buffer::None; @@ -187,7 +187,7 @@ impl<'a> AioCb<'a> { /// /// It is an error to call this method while the `AioCb` is still in /// progress. - pub fn boxed_mut_slice(&mut self) -> Option>> { + pub fn boxed_mut_slice(&mut self) -> Option>> { assert!(!self.in_progress, "Can't remove the buffer from an AioCb that's still in-progress. Did you forget to call aio_return?"); if let Buffer::BoxedMutSlice(_) = self.buffer { let mut oldbuffer = Buffer::None; @@ -448,12 +448,12 @@ impl<'a> AioCb<'a> { /// ``` /// /// [`from_slice`]: #method.from_slice - pub fn from_boxed_slice(fd: RawFd, offs: off_t, buf: Box>, + pub fn from_boxed_slice(fd: RawFd, offs: off_t, buf: Box>, prio: libc::c_int, sigev_notify: SigevNotify, opcode: LioOpcode) -> AioCb<'a> { let mut a = AioCb::common_init(fd, prio, sigev_notify); { - let borrowed : &Borrow<[u8]> = buf.borrow(); + let borrowed : &dyn Borrow<[u8]> = buf.borrow(); let slice : &[u8] = borrowed.borrow(); a.aio_nbytes = slice.len() as size_t; a.aio_buf = slice.as_ptr() as *mut c_void; @@ -516,12 +516,12 @@ impl<'a> AioCb<'a> { /// [`from_boxed_slice`]: #method.from_boxed_slice /// [`from_mut_slice`]: #method.from_mut_slice pub fn from_boxed_mut_slice(fd: RawFd, offs: off_t, - mut buf: Box>, + mut buf: Box>, prio: libc::c_int, sigev_notify: SigevNotify, opcode: LioOpcode) -> AioCb<'a> { let mut a = AioCb::common_init(fd, prio, sigev_notify); { - let borrowed : &mut BorrowMut<[u8]> = buf.borrow_mut(); + let borrowed : &mut dyn BorrowMut<[u8]> = buf.borrow_mut(); let slice : &mut [u8] = borrowed.borrow_mut(); a.aio_nbytes = slice.len() as size_t; a.aio_buf = slice.as_mut_ptr() as *mut c_void; diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 0e27216fbb..d651b2593d 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -893,7 +893,7 @@ pub fn sendmsg(fd: RawFd, iov: &[IoVec<&[u8]>], cmsgs: &[ControlMessage], /// # References /// [recvmsg(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html) pub fn recvmsg<'a>(fd: RawFd, iov: &[IoVec<&mut [u8]>], - cmsg_buffer: Option<&'a mut CmsgBuffer>, + cmsg_buffer: Option<&'a mut dyn CmsgBuffer>, flags: MsgFlags) -> Result> { let mut address: sockaddr_storage = unsafe { mem::uninitialized() }; diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs index 12afc84cca..a71d276746 100644 --- a/test/sys/test_socket.rs +++ b/test/sys/test_socket.rs @@ -1,4 +1,5 @@ -use nix::sys::socket::{InetAddr, UnixAddr, getsockname}; +use nix::ifaddrs::InterfaceAddress; +use nix::sys::socket::{AddressFamily, InetAddr, UnixAddr, getsockname}; use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use std::net::{self, Ipv6Addr, SocketAddr, SocketAddrV6}; @@ -302,7 +303,7 @@ pub fn test_af_alg_cipher() { #[cfg(any(target_os = "linux", target_os= "android"))] #[test] pub fn test_af_alg_aead() { - use libc; + use libc::{ALG_OP_DECRYPT, ALG_OP_ENCRYPT}; use nix::sys::uio::IoVec; use nix::unistd::{read, close}; use nix::sys::socket::{socket, sendmsg, bind, accept, setsockopt, @@ -345,7 +346,7 @@ pub fn test_af_alg_aead() { let session_socket = accept(sock).expect("accept failed"); let msgs = [ - ControlMessage::AlgSetOp(&libc::ALG_OP_ENCRYPT), + ControlMessage::AlgSetOp(&ALG_OP_ENCRYPT), ControlMessage::AlgSetIv(iv.as_slice()), ControlMessage::AlgSetAeadAssoclen(&assoc_size)]; let iov = IoVec::from_slice(&payload); @@ -368,7 +369,7 @@ pub fn test_af_alg_aead() { let session_socket = accept(sock).expect("accept failed"); let msgs = [ - ControlMessage::AlgSetOp(&libc::ALG_OP_DECRYPT), + ControlMessage::AlgSetOp(&ALG_OP_DECRYPT), ControlMessage::AlgSetIv(iv.as_slice()), ControlMessage::AlgSetAeadAssoclen(&assoc_size), ]; @@ -547,11 +548,11 @@ fn test_too_large_cmsgspace() { #[cfg(any(target_os = "android", target_os = "linux"))] fn test_impl_scm_credentials_and_rights(mut space: Vec) { - use libc; + use libc::ucred; use nix::sys::uio::IoVec; use nix::unistd::{pipe, read, write, close, getpid, getuid, getgid}; use nix::sys::socket::{socketpair, sendmsg, recvmsg, setsockopt, - AddressFamily, SockType, SockFlag, + SockType, SockFlag, ControlMessage, ControlMessageOwned, MsgFlags}; use nix::sys::socket::sockopt::PassCred; @@ -564,7 +565,7 @@ fn test_impl_scm_credentials_and_rights(mut space: Vec) { { let iov = [IoVec::from_slice(b"hello")]; - let cred = libc::ucred { + let cred = ucred { pid: getpid().as_raw(), uid: getuid().as_raw(), gid: getgid().as_raw(), @@ -623,7 +624,7 @@ fn test_impl_scm_credentials_and_rights(mut space: Vec) { // Test creating and using named unix domain sockets #[test] pub fn test_unixdomain() { - use nix::sys::socket::{AddressFamily, SockType, SockFlag}; + use nix::sys::socket::{SockType, SockFlag}; use nix::sys::socket::{bind, socket, connect, listen, accept, SockAddr}; use nix::unistd::{read, write, close}; use std::thread; @@ -661,7 +662,7 @@ pub fn test_unixdomain() { pub fn test_syscontrol() { use nix::Error; use nix::errno::Errno; - use nix::sys::socket::{AddressFamily, socket, SockAddr, SockType, SockFlag, SockProtocol}; + use nix::sys::socket::{socket, SockAddr, SockType, SockFlag, SockProtocol}; let fd = socket(AddressFamily::System, SockType::Datagram, SockFlag::empty(), SockProtocol::KextControl) @@ -673,8 +674,6 @@ pub fn test_syscontrol() { // connect(fd, &sockaddr).expect("connect failed"); } -use nix::ifaddrs::InterfaceAddress; -use nix::sys::socket::AddressFamily; #[cfg(any( target_os = "android", target_os = "freebsd", @@ -942,7 +941,7 @@ pub fn test_recv_ipv6pktinfo() { use libc; use nix::net::if_::*; use nix::sys::socket::sockopt::Ipv6RecvPacketInfo; - use nix::sys::socket::{bind, AddressFamily, SockFlag, SockType}; + use nix::sys::socket::{bind, SockFlag, SockType}; use nix::sys::socket::{getsockname, setsockopt, socket}; use nix::sys::socket::{recvmsg, sendmsg, ControlMessageOwned, MsgFlags}; use nix::sys::uio::IoVec; From 43df789bda3aba17ad1a0405e506a376c94bd73c Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Thu, 11 Jul 2019 11:47:01 -0600 Subject: [PATCH 2/3] Do "cargo check" instead of "cargo build" for the MSRV check check is faster than build. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 917105e6a7..664905a29a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -94,7 +94,7 @@ matrix: - rust: nightly script: - cargo update -Zminimal-versions - - cargo build + - cargo check before_install: set -e From 2373ac817f331991d12dd0d1bccb20bb69300f6e Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Thu, 11 Jul 2019 17:44:48 -0600 Subject: [PATCH 3/3] Temporarily allow deprecated items This fixes the tests on Rust 1.38.0. We'll fix them for real after release 0.15.0. Issue #1096 --- src/lib.rs | 2 ++ test/test.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 22577cfe63..71485d2af1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,8 @@ #![deny(unstable_features)] #![deny(missing_copy_implementations)] #![deny(missing_debug_implementations)] +// XXX Allow deprecated items until release 0.16.0. See issue #1096. +#![allow(deprecated)] // External crates #[macro_use] diff --git a/test/test.rs b/test/test.rs index 4c7e5b1e95..6a71d261b5 100644 --- a/test/test.rs +++ b/test/test.rs @@ -1,3 +1,5 @@ +// XXX Allow deprecated items until release 0.16.0. See issue #1096. +#![allow(deprecated)] extern crate bytes; #[cfg(any(target_os = "android", target_os = "linux"))] extern crate caps;