diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e827f147f..e352385c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ env: RUST_BACKTRACE: 1 RUSTUP_WINDOWS_PATH_ADD_BIN: 1 # Change to specific Rust release to pin - rust_stable: '1.93.1' + rust_stable: stable rust_nightly: nightly-2025-10-12 # Pin a specific miri version rust_miri_nightly: nightly-2025-11-13 @@ -1057,6 +1057,8 @@ 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 27e98b5b2..ee88c380a 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(unix)] +#[cfg(all(unix, not(test)))] use std::os::unix::fs::OpenOptionsExt; -#[cfg(windows)] +#[cfg(all(windows, not(test)))] 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 2fbdd282a..0ff4c8bc9 100644 --- a/tokio/src/fs/open_options/mock_open_options.rs +++ b/tokio/src/fs/open_options/mock_open_options.rs @@ -3,10 +3,6 @@ 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! { @@ -19,21 +15,25 @@ 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 48297ca3b..4e7660413 100644 --- a/tokio/src/fs/open_options/uring_open_options.rs +++ b/tokio/src/fs/open_options/uring_open_options.rs @@ -1,4 +1,7 @@ -use std::{io, os::unix::fs::OpenOptionsExt}; +use std::io; + +#[cfg(not(test))] +use std::os::unix::fs::OpenOptionsExt; #[cfg(test)] use super::mock_open_options::MockOpenOptions as StdOpenOptions;