diff --git a/.cirrus.yml b/.cirrus.yml index f18d58354..bcafac2f3 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -16,7 +16,7 @@ env: task: name: FreeBSD 64-bit setup_script: - - pkg install -y bash ca_root_nss + - pkg install -y bash - curl https://sh.rustup.rs -sSf --output rustup.sh - sh rustup.sh -y --profile minimal --default-toolchain $RUST_STABLE - . $HOME/.cargo/env @@ -42,7 +42,7 @@ task: RUSTFLAGS: --cfg docsrs --cfg tokio_unstable RUSTDOCFLAGS: --cfg docsrs --cfg tokio_unstable -Dwarnings setup_script: - - pkg install -y bash ca_root_nss + - pkg install -y bash - curl https://sh.rustup.rs -sSf --output rustup.sh - sh rustup.sh -y --profile minimal --default-toolchain $RUST_NIGHTLY - . $HOME/.cargo/env @@ -58,7 +58,7 @@ task: task: name: FreeBSD 32-bit setup_script: - - pkg install -y bash ca_root_nss + - pkg install -y bash - curl https://sh.rustup.rs -sSf --output rustup.sh - sh rustup.sh -y --profile minimal --default-toolchain $RUST_STABLE - . $HOME/.cargo/env diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52c7fd1b5..c64225733 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1060,8 +1060,6 @@ jobs: target: - wasm32-wasip1 - wasm32-wasip1-threads - env: - rust_stable: '1.93.1' steps: - uses: actions/checkout@v4 - name: Install Rust ${{ env.rust_stable }} diff --git a/tokio/src/fs/open_options.rs b/tokio/src/fs/open_options.rs index ee88c380a..27e98b5b2 100644 --- a/tokio/src/fs/open_options.rs +++ b/tokio/src/fs/open_options.rs @@ -16,9 +16,9 @@ use mock_open_options::MockOpenOptions as StdOpenOptions; #[cfg(not(test))] use std::fs::OpenOptions as StdOpenOptions; -#[cfg(all(unix, not(test)))] +#[cfg(unix)] use std::os::unix::fs::OpenOptionsExt; -#[cfg(all(windows, not(test)))] +#[cfg(windows)] use std::os::windows::fs::OpenOptionsExt; /// Options and flags which can be used to configure how a file is opened. diff --git a/tokio/src/fs/open_options/mock_open_options.rs b/tokio/src/fs/open_options/mock_open_options.rs index 0ff4c8bc9..2fbdd282a 100644 --- a/tokio/src/fs/open_options/mock_open_options.rs +++ b/tokio/src/fs/open_options/mock_open_options.rs @@ -3,6 +3,10 @@ use mockall::mock; use crate::fs::mocks::MockFile; +#[cfg(unix)] +use std::os::unix::fs::OpenOptionsExt; +#[cfg(windows)] +use std::os::windows::fs::OpenOptionsExt; use std::{io, path::Path}; mock! { @@ -15,25 +19,21 @@ mock! { pub fn read(&mut self, read: bool) -> &mut Self; pub fn truncate(&mut self, truncate: bool) -> &mut Self; pub fn write(&mut self, write: bool) -> &mut Self; - - // Not mocking OpenOptionsExt trait due to: - // https://github.com/rust-lang/rust/issues/153486 - #[cfg(unix)] - pub fn custom_flags(&mut self, flags: i32) -> &mut Self; - #[cfg(unix)] - pub fn mode(&mut self, mode: u32) -> &mut Self; - #[cfg(windows)] - pub fn access_mode(&mut self, access: u32) -> &mut Self; - #[cfg(windows)] - pub fn share_mode(&mut self, val: u32) -> &mut Self; - #[cfg(windows)] - pub fn custom_flags(&mut self, flags: u32) -> &mut Self; - #[cfg(windows)] - pub fn attributes(&mut self, val: u32) -> &mut Self; - #[cfg(windows)] - pub fn security_qos_flags(&mut self, flags: u32) -> &mut Self; } impl Clone for OpenOptions { fn clone(&self) -> Self; } + #[cfg(unix)] + impl OpenOptionsExt for OpenOptions { + fn custom_flags(&mut self, flags: i32) -> &mut Self; + fn mode(&mut self, mode: u32) -> &mut Self; + } + #[cfg(windows)] + impl OpenOptionsExt for OpenOptions { + fn access_mode(&mut self, access: u32) -> &mut Self; + fn share_mode(&mut self, val: u32) -> &mut Self; + fn custom_flags(&mut self, flags: u32) -> &mut Self; + fn attributes(&mut self, val: u32) -> &mut Self; + fn security_qos_flags(&mut self, flags: u32) -> &mut Self; + } } diff --git a/tokio/src/fs/open_options/uring_open_options.rs b/tokio/src/fs/open_options/uring_open_options.rs index 4e7660413..48297ca3b 100644 --- a/tokio/src/fs/open_options/uring_open_options.rs +++ b/tokio/src/fs/open_options/uring_open_options.rs @@ -1,7 +1,4 @@ -use std::io; - -#[cfg(not(test))] -use std::os::unix::fs::OpenOptionsExt; +use std::{io, os::unix::fs::OpenOptionsExt}; #[cfg(test)] use super::mock_open_options::MockOpenOptions as StdOpenOptions;