Skip to content

Commit

Permalink
Merge #1862
Browse files Browse the repository at this point in the history
1862: Bump MSRV to 1.63 for I/O safety r=asomers a=SUPERCILEX

Prep for #1750

Co-authored-by: Alex Saveau <[email protected]>
  • Loading branch information
bors[bot] and SUPERCILEX authored Dec 4, 2022
2 parents 3286c4d + bc2b023 commit e756c96
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 80 deletions.
12 changes: 6 additions & 6 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
RUSTDOCFLAGS: -D warnings
TOOL: cargo
# The MSRV
TOOLCHAIN: 1.56.1
TOOLCHAIN: 1.63.0
ZFLAGS:

# Tests that don't require executing the build binaries
Expand Down Expand Up @@ -140,18 +140,18 @@ task:
matrix:
- name: Linux aarch64
arm_container:
image: rust:1.56
image: rust:1.63.0
env:
RUSTFLAGS: --cfg graviton -D warnings
TARGET: aarch64-unknown-linux-gnu
- name: Linux x86_64
container:
image: rust:1.56
image: rust:1.63.0
env:
TARGET: x86_64-unknown-linux-gnu
- name: Linux x86_64 musl
container:
image: rust:1.56
image: rust:1.63.0
env:
TARGET: x86_64-unknown-linux-musl
setup_script:
Expand All @@ -176,7 +176,7 @@ task:
# Tasks for cross-compiling, but no testing
task:
container:
image: rust:1.56
image: rust:1.63.0
env:
BUILD: check
HOST: x86_64-unknown-linux-gnu
Expand Down Expand Up @@ -250,7 +250,7 @@ task:

task:
container:
image: rust:1.56
image: rust:1.63.0
env:
BUILD: check
name: Redox x86_64
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ This project adheres to [Semantic Versioning](https://semver.org/).
(#[1662](https://github.com/nix-rust/nix/pull/1662))

### Changed

- The MSRV is now 1.63
([#1862](https://github.com/nix-rust/nix/pull/1862))

### Fixed
### Removed

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "nix"
description = "Rust friendly bindings to *nix APIs"
edition = "2018"
edition = "2021"
version = "0.26.1"
rust-version = "1.56"
rust-version = "1.63"
authors = ["The nix-rust Project Developers"]
repository = "https://github.com/nix-rust/nix"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Tier 3:

## Minimum Supported Rust Version (MSRV)

nix is supported on Rust 1.56.1 and higher. Its MSRV will not be
nix is supported on Rust 1.63 and higher. Its MSRV will not be
changed in the future without bumping the major or minor version.

## Contributing
Expand Down
2 changes: 1 addition & 1 deletion src/sys/aio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl AioCb {
0 => Ok(()),
num if num > 0 => Err(Errno::from_i32(num)),
-1 => Err(Errno::last()),
num => panic!("unknown aio_error return value {:?}", num),
num => panic!("unknown aio_error return value {num:?}"),
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/sys/socket/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2373,7 +2373,7 @@ mod tests {
sdl_slen: 0,
..unsafe { mem::zeroed() }
});
format!("{}", la);
format!("{la}");
}

#[cfg(all(
Expand Down Expand Up @@ -2495,7 +2495,7 @@ mod tests {
fn display() {
let s = "127.0.0.1:8080";
let addr = SockaddrIn::from_str(s).unwrap();
assert_eq!(s, format!("{}", addr));
assert_eq!(s, format!("{addr}"));
}

#[test]
Expand All @@ -2515,7 +2515,7 @@ mod tests {
fn display() {
let s = "[1234:5678:90ab:cdef::1111:2222]:8080";
let addr = SockaddrIn6::from_str(s).unwrap();
assert_eq!(s, format!("{}", addr));
assert_eq!(s, format!("{addr}"));
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion src/sys/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use libc::{
self, c_int, c_void, iovec, size_t, socklen_t, CMSG_DATA, CMSG_FIRSTHDR,
CMSG_LEN, CMSG_NXTHDR,
};
use std::convert::TryFrom;
use std::io::{IoSlice, IoSliceMut};
#[cfg(feature = "net")]
use std::net;
Expand Down
5 changes: 1 addition & 4 deletions src/sys/socket/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ use crate::Result;
use cfg_if::cfg_if;
use libc::{self, c_int, c_void, socklen_t};
use std::ffi::{OsStr, OsString};
use std::mem::{self, MaybeUninit};
#[cfg(target_family = "unix")]
use std::os::unix::ffi::OsStrExt;
use std::os::unix::io::RawFd;
use std::{
convert::TryFrom,
mem::{self, MaybeUninit},
};

// Constants
// TCP_CA_NAME_MAX isn't defined in user space include files
Expand Down
32 changes: 15 additions & 17 deletions src/sys/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ impl TimeValLike for TimeSpec {
fn seconds(seconds: i64) -> TimeSpec {
assert!(
(TS_MIN_SECONDS..=TS_MAX_SECONDS).contains(&seconds),
"TimeSpec out of bounds; seconds={}",
seconds
"TimeSpec out of bounds; seconds={seconds}",
);
let mut ts = zero_init_timespec();
ts.tv_sec = seconds as time_t;
Expand Down Expand Up @@ -428,20 +427,20 @@ impl fmt::Display for TimeSpec {

let sec = abs.tv_sec();

write!(f, "{}", sign)?;
write!(f, "{sign}")?;

if abs.tv_nsec() == 0 {
if abs.tv_sec() == 1 {
write!(f, "{} second", sec)?;
if sec == 1 {
write!(f, "1 second")?;
} else {
write!(f, "{} seconds", sec)?;
write!(f, "{sec} seconds")?;
}
} else if abs.tv_nsec() % 1_000_000 == 0 {
write!(f, "{}.{:03} seconds", sec, abs.tv_nsec() / 1_000_000)?;
write!(f, "{sec}.{:03} seconds", abs.tv_nsec() / 1_000_000)?;
} else if abs.tv_nsec() % 1_000 == 0 {
write!(f, "{}.{:06} seconds", sec, abs.tv_nsec() / 1_000)?;
write!(f, "{sec}.{:06} seconds", abs.tv_nsec() / 1_000)?;
} else {
write!(f, "{}.{:09} seconds", sec, abs.tv_nsec())?;
write!(f, "{sec}.{:09} seconds", abs.tv_nsec())?;
}

Ok(())
Expand Down Expand Up @@ -497,8 +496,7 @@ impl TimeValLike for TimeVal {
fn seconds(seconds: i64) -> TimeVal {
assert!(
(TV_MIN_SECONDS..=TV_MAX_SECONDS).contains(&seconds),
"TimeVal out of bounds; seconds={}",
seconds
"TimeVal out of bounds; seconds={seconds}"
);
#[cfg_attr(target_env = "musl", allow(deprecated))]
// https://github.com/rust-lang/libc/issues/1848
Expand Down Expand Up @@ -662,18 +660,18 @@ impl fmt::Display for TimeVal {

let sec = abs.tv_sec();

write!(f, "{}", sign)?;
write!(f, "{sign}")?;

if abs.tv_usec() == 0 {
if abs.tv_sec() == 1 {
write!(f, "{} second", sec)?;
if sec == 1 {
write!(f, "1 second")?;
} else {
write!(f, "{} seconds", sec)?;
write!(f, "{sec} seconds")?;
}
} else if abs.tv_usec() % 1000 == 0 {
write!(f, "{}.{:03} seconds", sec, abs.tv_usec() / 1000)?;
write!(f, "{sec}.{:03} seconds", abs.tv_usec() / 1000)?;
} else {
write!(f, "{}.{:06} seconds", sec, abs.tv_usec())?;
write!(f, "{sec}.{:06} seconds", abs.tv_usec())?;
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion test/sys/test_aio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ fn test_aio_suspend() {
let r = aio_suspend(&cbbuf[..], Some(timeout));
match r {
Err(Errno::EINTR) => continue,
Err(e) => panic!("aio_suspend returned {:?}", e),
Err(e) => panic!("aio_suspend returned {e:?}"),
Ok(_) => (),
};
}
Expand Down
8 changes: 3 additions & 5 deletions test/sys/test_signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ fn test_sigprocmask() {
// test don't make sense.
assert!(
!old_signal_set.contains(SIGNAL),
"the {:?} signal is already blocked, please change to a \
different one",
SIGNAL
"the {SIGNAL:?} signal is already blocked, please change to a \
different one"
);

// Now block the signal.
Expand All @@ -71,8 +70,7 @@ fn test_sigprocmask() {
.expect("expect to be able to retrieve old signals");
assert!(
old_signal_set.contains(SIGNAL),
"expected the {:?} to be blocked",
SIGNAL
"expected the {SIGNAL:?} to be blocked"
);

// Reset the signal.
Expand Down
12 changes: 6 additions & 6 deletions test/sys/test_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ mod recvfrom {
println!("IPv6 not available, skipping test.");
return;
}
Err(e) => panic!("bind: {}", e),
Err(e) => panic!("bind: {e}"),
Ok(()) => (),
}
let ssock = socket(
Expand Down Expand Up @@ -1272,7 +1272,7 @@ fn test_scm_credentials() {
ControlMessageOwned::ScmCredentials(cred) => cred,
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
ControlMessageOwned::ScmCreds(cred) => cred,
other => panic!("unexpected cmsg {:?}", other),
other => panic!("unexpected cmsg {other:?}"),
};
assert!(received_cred.is_none());
assert_eq!(cred.pid(), getpid().as_raw());
Expand Down Expand Up @@ -1550,7 +1550,7 @@ fn loopback_address(
Err(e) => {
let stdioerr = io::stderr();
let mut handle = stdioerr.lock();
writeln!(handle, "getifaddrs: {:?}", e).unwrap();
writeln!(handle, "getifaddrs: {e:?}").unwrap();
return None;
}
};
Expand Down Expand Up @@ -2347,7 +2347,7 @@ mod linux_errqueue {
}
*ext_err
} else {
panic!("Unexpected control message {:?}", cmsg);
panic!("Unexpected control message {cmsg:?}");
}
},
)
Expand Down Expand Up @@ -2398,7 +2398,7 @@ mod linux_errqueue {
}
*ext_err
} else {
panic!("Unexpected control message {:?}", cmsg);
panic!("Unexpected control message {cmsg:?}");
}
},
)
Expand Down Expand Up @@ -2432,7 +2432,7 @@ mod linux_errqueue {
MsgFlags::empty(),
) {
assert_eq!(e, Errno::EADDRNOTAVAIL);
println!("{:?} not available, skipping test.", af);
println!("{af:?} not available, skipping test.");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test/test_fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ mod test_posix_fallocate {
let err = posix_fallocate(rd as RawFd, 0, 100).unwrap_err();
match err {
Errno::EINVAL | Errno::ENODEV | Errno::ESPIPE | Errno::EBADF => (),
errno => panic!("unexpected errno {}", errno,),
errno => panic!("unexpected errno {errno}",),
}
}
}
Loading

0 comments on commit e756c96

Please sign in to comment.