From 419ffd10b431546ddd7bba313d63c18bb3887720 Mon Sep 17 00:00:00 2001 From: Serge Barral Date: Sun, 8 Sep 2024 21:26:11 +0200 Subject: [PATCH] Update Loom, make it a dev dependency --- Cargo.toml | 9 +++++---- src/lib.rs | 6 ------ src/loom_exports.rs | 12 ++++++------ 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1491459..75ce195 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ name = "tachyonix" version = "0.3.0" authors = ["Serge Barral "] edition = "2021" -rust-version = "1.77" +rust-version = "1.56" license = "MIT OR Apache-2.0" repository = "https://github.com/asynchronics/tachyonix" readme = "README.md" @@ -26,9 +26,6 @@ diatomic-waker = "0.1" futures-core = "0.3" pin-project-lite = "0.2" -[target.'cfg(tachyonix_loom)'.dependencies] -loom = "0.5" - [dev-dependencies] futures-executor = { version = "0.3", default-features = false, features = ["thread-pool"] } futures-task = { version = "0.3", default-features = false, features = ["std"] } @@ -36,8 +33,12 @@ futures-util = { version = "0.3", default-features = false, features = ["std", " futures-time = "3.0" [target.'cfg(tachyonix_loom)'.dev-dependencies] +loom = "0.7" waker-fn = "1.1" +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tachyonix_loom)'] } + [[test]] name = "integration" path = "tests/tests.rs" diff --git a/src/lib.rs b/src/lib.rs index 577ce2a..6d88934 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,12 +37,6 @@ //! # std::thread::sleep(std::time::Duration::from_millis(100)); // MIRI bug workaround //! ``` //! - -// Temporary workaround until the `async_event_loom` flag can be whitelisted -// without a `build.rs` [1]. -// -// [1]: (https://github.com/rust-lang/rust/issues/124800). -#![allow(unexpected_cfgs)] #![warn(missing_docs, missing_debug_implementations, unreachable_pub)] mod loom_exports; diff --git a/src/loom_exports.rs b/src/loom_exports.rs index c2079ce..51a4ad6 100644 --- a/src/loom_exports.rs +++ b/src/loom_exports.rs @@ -1,4 +1,4 @@ -#[cfg(tachyonix_loom)] +#[cfg(all(test, tachyonix_loom))] #[allow(unused_imports)] pub(crate) mod sync { pub(crate) use loom::sync::{Arc, Mutex}; @@ -7,7 +7,7 @@ pub(crate) mod sync { pub(crate) use loom::sync::atomic::{AtomicBool, AtomicUsize}; } } -#[cfg(not(tachyonix_loom))] +#[cfg(not(all(test, tachyonix_loom)))] #[allow(unused_imports)] pub(crate) mod sync { pub(crate) use std::sync::{Arc, Mutex}; @@ -17,11 +17,11 @@ pub(crate) mod sync { } } -#[cfg(tachyonix_loom)] +#[cfg(all(test, tachyonix_loom))] pub(crate) mod cell { pub(crate) use loom::cell::UnsafeCell; } -#[cfg(not(tachyonix_loom))] +#[cfg(not(all(test, tachyonix_loom)))] pub(crate) mod cell { #[derive(Debug)] pub(crate) struct UnsafeCell(std::cell::UnsafeCell); @@ -45,11 +45,11 @@ pub(crate) mod cell { #[allow(unused_macros)] macro_rules! debug_or_loom_assert { - ($($arg:tt)*) => (if cfg!(any(debug_assertions, tachyonix_loom)) { assert!($($arg)*); }) + ($($arg:tt)*) => (if cfg!(any(debug_assertions, all(test, tachyonix_loom))) { assert!($($arg)*); }) } #[allow(unused_macros)] macro_rules! debug_or_loom_assert_eq { - ($($arg:tt)*) => (if cfg!(any(debug_assertions, tachyonix_loom)) { assert_eq!($($arg)*); }) + ($($arg:tt)*) => (if cfg!(any(debug_assertions, all(test, tachyonix_loom))) { assert_eq!($($arg)*); }) } #[allow(unused_imports)] pub(crate) use debug_or_loom_assert;