Skip to content

Commit 2f4861f

Browse files
authored
Raise MSRV to 1.69.0 (#2144)
* Raise MSRV to 1.69.0 This allows us to use the very useful CStr::from_bytes_until_nul * Respond to review comments * Switch the name of the Fuchsia CI target x86_64-fuchsia -> x86_64-unknown-fuchsia
1 parent 591e2ed commit 2f4861f

File tree

6 files changed

+26
-28
lines changed

6 files changed

+26
-28
lines changed

.cirrus.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
RUSTFLAGS: -D warnings
1010
RUSTDOCFLAGS: -D warnings
1111
TOOL: cargo
12-
MSRV: 1.65.0
12+
MSRV: 1.69.0
1313
ZFLAGS:
1414

1515
# Tests that don't require executing the build binaries
@@ -146,7 +146,7 @@ task:
146146
matrix:
147147
- name: Linux aarch64
148148
arm_container:
149-
image: rust:1.65.0
149+
image: rust:1.69.0
150150
cpu: 1
151151
depends_on:
152152
- FreeBSD 14 amd64 & i686
@@ -160,13 +160,13 @@ task:
160160
TARGET: aarch64-unknown-linux-gnu
161161
- name: Linux x86_64
162162
container:
163-
image: rust:1.65.0
163+
image: rust:1.69.0
164164
cpu: 1
165165
env:
166166
TARGET: x86_64-unknown-linux-gnu
167167
- name: Linux x86_64 musl
168168
container:
169-
image: rust:1.65.0
169+
image: rust:1.69.0
170170
cpu: 1
171171
depends_on:
172172
- FreeBSD 14 amd64 & i686
@@ -199,7 +199,7 @@ task:
199199
# Tasks for cross-compiling, but no testing
200200
task:
201201
container:
202-
image: rust:1.65.0
202+
image: rust:1.69.0
203203
cpu: 1
204204
depends_on:
205205
- FreeBSD 14 amd64 & i686
@@ -235,7 +235,7 @@ task:
235235
TARGET: arm-unknown-linux-musleabi
236236
- name: Fuchsia x86_64
237237
env:
238-
TARGET: x86_64-fuchsia
238+
TARGET: x86_64-unknown-fuchsia
239239
- name: Illumos
240240
env:
241241
TARGET: x86_64-unknown-illumos

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1818

1919
### Changed
2020

21+
- The MSRV is now 1.69
22+
([#2144](https://github.com/nix-rust/nix/pull/2144))
23+
2124
- The following APIs now take an implementation of `AsFd` rather than a
2225
`RawFd`:
2326

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ The following targets are supported by `nix`:
105105

106106
## Minimum Supported Rust Version (MSRV)
107107

108-
nix is supported on Rust 1.65 and higher. Its MSRV will not be
108+
nix is supported on Rust 1.69 and higher. Its MSRV will not be
109109
changed in the future without bumping the major or minor version.
110110

111111
## Contributing

src/mount/bsd.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,10 @@ impl<'a> Nmount<'a> {
396396
match Errno::result(res) {
397397
Ok(_) => Ok(()),
398398
Err(error) => {
399-
let errmsg = match errmsg.iter().position(|&x| x == 0) {
400-
None => None,
401-
Some(0) => None,
402-
Some(n) => {
403-
let sl = &errmsg[0..n + 1];
404-
Some(CStr::from_bytes_with_nul(sl).unwrap())
405-
}
399+
let errmsg = if errmsg[0] == 0 {
400+
None
401+
} else {
402+
CStr::from_bytes_until_nul(&errmsg[..]).ok()
406403
};
407404
Err(NmountError::new(error, errmsg))
408405
}

src/sys/prctl.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,11 @@ pub fn get_name() -> Result<CString> {
151151

152152
let res = unsafe { libc::prctl(libc::PR_GET_NAME, &buf, 0, 0, 0) };
153153

154-
let len = buf.iter().position(|&c| c == 0).unwrap_or(buf.len());
155-
let name = CStr::from_bytes_with_nul(&buf[..=len]).map_err(|_| Errno::EINVAL)?;
156-
157-
Errno::result(res).map(|_| name.to_owned())
154+
Errno::result(res).and_then(|_| {
155+
CStr::from_bytes_until_nul(&buf)
156+
.map(CStr::to_owned)
157+
.map_err(|_| Errno::EINVAL)
158+
})
158159
}
159160

160161
/// Sets the timer slack value for the calling thread. Timer slack is used by the kernel to group

src/unistd.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@ use libc::{
2828
uid_t, PATH_MAX,
2929
};
3030
use std::convert::Infallible;
31-
use std::ffi::{CStr, OsString};
3231
#[cfg(not(target_os = "redox"))]
33-
use std::ffi::{CString, OsStr};
34-
#[cfg(not(target_os = "redox"))]
35-
use std::os::unix::ffi::OsStrExt;
36-
use std::os::unix::ffi::OsStringExt;
37-
use std::os::unix::io::RawFd;
38-
use std::os::unix::io::{AsFd, AsRawFd, OwnedFd};
32+
use std::ffi::CString;
33+
use std::ffi::{CStr, OsStr, OsString};
34+
use std::os::unix::ffi::{OsStrExt, OsStringExt};
35+
use std::os::unix::io::{AsFd, AsRawFd, OwnedFd, RawFd};
3936
use std::path::PathBuf;
4037
use std::{fmt, mem, ptr};
4138

@@ -3928,9 +3925,9 @@ pub fn ttyname<F: AsFd>(fd: F) -> Result<PathBuf> {
39283925
return Err(Errno::from_i32(ret));
39293926
}
39303927

3931-
let nul = buf.iter().position(|c| *c == b'\0').unwrap();
3932-
buf.truncate(nul);
3933-
Ok(OsString::from_vec(buf).into())
3928+
CStr::from_bytes_until_nul(&buf[..])
3929+
.map(|s| OsStr::from_bytes(s.to_bytes()).into())
3930+
.map_err(|_| Errno::EINVAL)
39343931
}
39353932
}
39363933

0 commit comments

Comments
 (0)