From 114c148114af9f6411298cbbe8102e41bf8c4eb3 Mon Sep 17 00:00:00 2001 From: Serge Barral Date: Sat, 7 Sep 2024 19:53:30 +0200 Subject: [PATCH] Move loom as a dev-dependency --- asynchronix/Cargo.toml | 11 ++++++----- asynchronix/build.rs | 3 --- asynchronix/src/loom_exports.rs | 8 ++++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/asynchronix/Cargo.toml b/asynchronix/Cargo.toml index ea2f278..43fa866 100644 --- a/asynchronix/Cargo.toml +++ b/asynchronix/Cargo.toml @@ -67,20 +67,21 @@ tonic = { version = "0.11", default-features = false, features=["codegen", "pros # WASM service dependencies. wasm-bindgen = { version = "0.2", optional = true } -[target.'cfg(asynchronix_loom)'.dependencies] -loom = "0.5" -waker-fn = "1.1" - - [dev-dependencies] atomic-wait = "1.1" futures-util = "0.3" futures-executor = "0.3" mio = { version = "1.0", features = ["os-poll", "net"] } +[target.'cfg(asynchronix_loom)'.dev-dependencies] +loom = "0.5" +waker-fn = "1.1" + [build-dependencies] tonic-build = { version = "0.11", optional = true } +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(asynchronix_loom)'] } [[test]] name = "integration" diff --git a/asynchronix/build.rs b/asynchronix/build.rs index d2bb66b..f6ce175 100644 --- a/asynchronix/build.rs +++ b/asynchronix/build.rs @@ -1,7 +1,4 @@ fn main() -> Result<(), Box> { - // Prevent warnings when checking for flag `asynchronix_loom`. - println!("cargo::rustc-check-cfg=cfg(asynchronix_loom)"); - #[cfg(feature = "rpc-codegen")] let builder = tonic_build::configure() .build_client(false) diff --git a/asynchronix/src/loom_exports.rs b/asynchronix/src/loom_exports.rs index df03e12..f168280 100644 --- a/asynchronix/src/loom_exports.rs +++ b/asynchronix/src/loom_exports.rs @@ -1,4 +1,4 @@ -#[cfg(asynchronix_loom)] +#[cfg(all(test, asynchronix_loom))] #[allow(unused_imports)] pub(crate) mod sync { pub(crate) use loom::sync::{Arc, LockResult, Mutex, MutexGuard}; @@ -10,7 +10,7 @@ pub(crate) mod sync { }; } } -#[cfg(not(asynchronix_loom))] +#[cfg(not(all(test, asynchronix_loom)))] #[allow(unused_imports)] pub(crate) mod sync { pub(crate) use std::sync::{Arc, LockResult, Mutex, MutexGuard, PoisonError}; @@ -22,11 +22,11 @@ pub(crate) mod sync { } } -#[cfg(asynchronix_loom)] +#[cfg(all(test, asynchronix_loom))] pub(crate) mod cell { pub(crate) use loom::cell::UnsafeCell; } -#[cfg(not(asynchronix_loom))] +#[cfg(not(all(test, asynchronix_loom)))] pub(crate) mod cell { #[derive(Debug)] pub(crate) struct UnsafeCell(std::cell::UnsafeCell);