Skip to content

Commit

Permalink
Update Loom, make it a dev dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
sbarral committed Sep 8, 2024
1 parent 93c0182 commit 419ffd1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name = "tachyonix"
version = "0.3.0"
authors = ["Serge Barral <[email protected]>"]
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"
Expand All @@ -26,18 +26,19 @@ 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"] }
futures-util = { version = "0.3", default-features = false, features = ["std", "async-await"] }
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"
6 changes: 0 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/loom_exports.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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};
Expand All @@ -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<T>(std::cell::UnsafeCell<T>);
Expand All @@ -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;
Expand Down

0 comments on commit 419ffd1

Please sign in to comment.