diff --git a/src/lib.rs b/src/lib.rs index d0af19f..b8b6e6b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,7 +67,7 @@ //! //! [`portable-atomic`]: https://crates.io/crates/portable-atomic -#![cfg_attr(all(not(feature = "std"), not(test)), no_std)] +#![cfg_attr(not(feature = "std"), no_std)] #![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)] #![doc( html_favicon_url = "https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png" @@ -76,7 +76,10 @@ html_logo_url = "https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png" )] +#[cfg(not(feature = "std"))] extern crate alloc; +#[cfg(feature = "std")] +extern crate std as alloc; #[cfg_attr(feature = "std", path = "std.rs")] #[cfg_attr(not(feature = "std"), path = "no_std.rs")] @@ -84,6 +87,7 @@ mod sys; mod notify; +#[cfg(not(feature = "std"))] use alloc::boxed::Box; use core::borrow::Borrow; @@ -1365,6 +1369,9 @@ fn __test_send_and_sync() { fn _assert_sync() {} _assert_send::>(); + _assert_sync::>(); + _assert_send::>(); + _assert_sync::>(); _assert_send::>(); _assert_sync::>(); _assert_send::>(); @@ -1410,6 +1417,7 @@ pub mod __private { impl core::panic::UnwindSafe for StackSlot<'_, T> {} impl core::panic::RefUnwindSafe for StackSlot<'_, T> {} unsafe impl Send for StackSlot<'_, T> {} + unsafe impl Sync for StackSlot<'_, T> {} impl<'ev, T> StackSlot<'ev, T> { /// Create a new `StackSlot` on the stack. diff --git a/src/no_std.rs b/src/no_std.rs index 1341103..f445ea6 100644 --- a/src/no_std.rs +++ b/src/no_std.rs @@ -832,7 +832,6 @@ unsafe impl Sync for Mutex {} #[cfg(test)] mod tests { use super::*; - use crate::Task; #[cfg(target_family = "wasm")] use wasm_bindgen_test::wasm_bindgen_test as test;