From 74f9fbcbe1a09c1cc25cd91b9435981d308f77f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 5 Jul 2023 17:11:32 +0300 Subject: [PATCH] Update to rustix 0.38 and update MSRV to 1.63 (#241) --- .github/workflows/ci.yml | 8 +------- Cargo.toml | 4 ++-- README.md | 2 +- src/file/imp/unix.rs | 10 +++++----- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2390d28ff..828f868d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: rust-version: - nightly - stable - - "1.48" + - "1.63" os: - ubuntu-latest - windows-latest @@ -27,12 +27,6 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust-version }} - # Workaround link failures if XCode 14 is combined with Rust <= 1.53 - - name: Downgrade to XCode 13 - if: ${{ matrix.os == 'macos-latest' && matrix.rust-version == '1.48' }} - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: '13' - name: Build run: cargo build - name: Test diff --git a/Cargo.toml b/Cargo.toml index 1f0f6cdbc..064307d49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ authors = [ ] documentation = "https://docs.rs/tempfile" edition = "2018" -rust-version = "1.48" +rust-version = "1.63" homepage = "https://stebalien.com/projects/tempfile-rs/" keywords = ["tempfile", "tmpfile", "filesystem"] license = "MIT OR Apache-2.0" @@ -21,7 +21,7 @@ cfg-if = "1" fastrand = "2.0.0" [target.'cfg(any(unix, target_os = "wasi"))'.dependencies] -rustix = { version = "0.37.11", features = ["fs"] } +rustix = { version = "0.38", features = ["fs"] } [target.'cfg(windows)'.dependencies.windows-sys] version = "0.48" diff --git a/README.md b/README.md index bf207f8a4..4d886b135 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ patterns and surprisingly difficult to implement securely). Usage ----- -Minimum required Rust version: 1.48.0 +Minimum required Rust version: 1.63.0 Add this to your `Cargo.toml`: diff --git a/src/file/imp/unix.rs b/src/file/imp/unix.rs index c305ea95e..fed4e02e7 100644 --- a/src/file/imp/unix.rs +++ b/src/file/imp/unix.rs @@ -14,7 +14,7 @@ use crate::util; use std::path::Path; #[cfg(not(target_os = "redox"))] -use rustix::fs::{cwd, linkat, renameat, unlinkat, AtFlags}; +use rustix::fs::{linkat, renameat, unlinkat, AtFlags, CWD}; pub fn create_named(path: &Path, open_options: &mut OpenOptions) -> io::Result { open_options.read(true).write(true).create_new(true); @@ -103,7 +103,7 @@ pub fn reopen(_file: &File, _path: &Path) -> io::Result { #[cfg(not(target_os = "redox"))] pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<()> { if overwrite { - renameat(cwd(), old_path, cwd(), new_path)?; + renameat(CWD, old_path, CWD, new_path)?; } else { // On Linux, use `renameat_with` to avoid overwriting an existing name, // if the kernel and the filesystem support it. @@ -115,7 +115,7 @@ pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result< static NOSYS: AtomicBool = AtomicBool::new(false); if !NOSYS.load(Relaxed) { - match renameat_with(cwd(), old_path, cwd(), new_path, RenameFlags::NOREPLACE) { + match renameat_with(CWD, old_path, CWD, new_path, RenameFlags::NOREPLACE) { Ok(()) => return Ok(()), Err(Errno::NOSYS) => NOSYS.store(true, Relaxed), Err(Errno::INVAL) => {} @@ -127,9 +127,9 @@ pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result< // Otherwise use `linkat` to create the new filesystem name, which // will fail if the name already exists, and then `unlinkat` to remove // the old name. - linkat(cwd(), old_path, cwd(), new_path, AtFlags::empty())?; + linkat(CWD, old_path, CWD, new_path, AtFlags::empty())?; // Ignore unlink errors. Can we do better? - let _ = unlinkat(cwd(), old_path, AtFlags::empty()); + let _ = unlinkat(CWD, old_path, AtFlags::empty()); } Ok(()) }