diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e7c5fbd5aa..1b6eb17b58 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -105,7 +105,7 @@ jobs: toolchain: - stable - nightly - - 1.36.0 + - 1.51.0 features: - serde buildtype: @@ -242,7 +242,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.36.0 + toolchain: 1.51.0 target: x86_64-unknown-linux-gnu override: true diff --git a/cfail/ui/freeze.rs b/cfail/ui/freeze.rs index d1adc1f1f7..b5e5ace6cf 100644 --- a/cfail/ui/freeze.rs +++ b/cfail/ui/freeze.rs @@ -1,7 +1,7 @@ -use heapless::{consts, spsc::Queue}; +use heapless::{spsc::Queue}; fn main() { - let mut q: Queue = Queue::new(); + let mut q: Queue = Queue::new(); let (_p, mut _c) = q.split(); q.enqueue(0).unwrap(); diff --git a/cfail/ui/not-send.rs b/cfail/ui/not-send.rs index cdd1359412..f5ea87c6b7 100644 --- a/cfail/ui/not-send.rs +++ b/cfail/ui/not-send.rs @@ -3,7 +3,6 @@ use core::marker::PhantomData; use heapless::{ - consts, spsc::{Consumer, Producer, Queue}, }; @@ -16,8 +15,8 @@ where } fn main() { - is_send::>(); - is_send::>(); - is_send::>(); - is_send::>(); + is_send::>(); + is_send::>(); + is_send::>(); + is_send::>(); } diff --git a/cfail/ui/not-send.stderr b/cfail/ui/not-send.stderr index a1813b629b..878e924353 100644 --- a/cfail/ui/not-send.stderr +++ b/cfail/ui/not-send.stderr @@ -1,83 +1,69 @@ error[E0277]: `*const ()` cannot be sent between threads safely - --> $DIR/not-send.rs:19:5 - | -19 | is_send::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely + --> $DIR/not-send.rs:18:5 | - = help: within `std::marker::PhantomData<*const ()>`, the trait `std::marker::Send` is not implemented for `*const ()` - = note: required because it appears within the type `std::marker::PhantomData<*const ()>` - = note: required because of the requirements on the impl of `std::marker::Send` for `heapless::spsc::split::Consumer<'_, std::marker::PhantomData<*const ()>, typenum::uint::UInt, typenum::bit::B0>, typenum::bit::B0>>` -note: required by `is_send` - --> $DIR/not-send.rs:12:1 +11 | fn is_send() + | ------- required by a bound in this +12 | where +13 | T: Send, + | ---- required by this bound in `is_send` +... +18 | is_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely | -12 | / fn is_send() -13 | | where -14 | | T: Send, -15 | | { -16 | | } - | |_^ + = help: within `PhantomData<*const ()>`, the trait `Send` is not implemented for `*const ()` + = note: required because it appears within the type `PhantomData<*const ()>` + = note: required because of the requirements on the impl of `Send` for `Consumer<'_, PhantomData<*const ()>, _, _, 4_usize>` error[E0277]: `*const ()` cannot be sent between threads safely - --> $DIR/not-send.rs:20:5 - | -20 | is_send::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely + --> $DIR/not-send.rs:19:5 | - = help: within `std::marker::PhantomData<*const ()>`, the trait `std::marker::Send` is not implemented for `*const ()` - = note: required because it appears within the type `std::marker::PhantomData<*const ()>` - = note: required because of the requirements on the impl of `std::marker::Send` for `heapless::spsc::split::Producer<'_, std::marker::PhantomData<*const ()>, typenum::uint::UInt, typenum::bit::B0>, typenum::bit::B0>>` -note: required by `is_send` - --> $DIR/not-send.rs:12:1 +11 | fn is_send() + | ------- required by a bound in this +12 | where +13 | T: Send, + | ---- required by this bound in `is_send` +... +19 | is_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely | -12 | / fn is_send() -13 | | where -14 | | T: Send, -15 | | { -16 | | } - | |_^ + = help: within `PhantomData<*const ()>`, the trait `Send` is not implemented for `*const ()` + = note: required because it appears within the type `PhantomData<*const ()>` + = note: required because of the requirements on the impl of `Send` for `Producer<'_, PhantomData<*const ()>, _, _, 4_usize>` error[E0277]: `*const ()` cannot be sent between threads safely - --> $DIR/not-send.rs:21:5 - | -21 | is_send::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely + --> $DIR/not-send.rs:20:5 | - = help: within `std::marker::PhantomData<*const ()>`, the trait `std::marker::Send` is not implemented for `*const ()` - = note: required because it appears within the type `std::marker::PhantomData<*const ()>` - = note: required because of the requirements on the impl of `std::marker::Send` for `generic_array::GenericArray, typenum::uint::UInt, typenum::bit::B0>, typenum::bit::B0>>` - = note: required because it appears within the type `std::mem::ManuallyDrop, typenum::uint::UInt, typenum::bit::B0>, typenum::bit::B0>>>` - = note: required because it appears within the type `std::mem::MaybeUninit, typenum::uint::UInt, typenum::bit::B0>, typenum::bit::B0>>>` - = note: required because it appears within the type `heapless::i::Queue, typenum::uint::UInt, typenum::bit::B0>, typenum::bit::B0>>>` - = note: required because it appears within the type `heapless::spsc::Queue, typenum::uint::UInt, typenum::bit::B0>, typenum::bit::B0>>` -note: required by `is_send` - --> $DIR/not-send.rs:12:1 +11 | fn is_send() + | ------- required by a bound in this +12 | where +13 | T: Send, + | ---- required by this bound in `is_send` +... +20 | is_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely | -12 | / fn is_send() -13 | | where -14 | | T: Send, -15 | | { -16 | | } - | |_^ + = help: within `Queue, _, _, 4_usize>`, the trait `Send` is not implemented for `*const ()` + = note: required because it appears within the type `PhantomData<*const ()>` + = note: required because it appears within the type `[PhantomData<*const ()>; 4]` + = note: required because it appears within the type `ManuallyDrop<[PhantomData<*const ()>; 4]>` + = note: required because it appears within the type `MaybeUninit<[PhantomData<*const ()>; 4]>` + = note: required because it appears within the type `Queue, _, _, 4_usize>` error[E0277]: `*const ()` cannot be sent between threads safely - --> $DIR/not-send.rs:22:5 - | -22 | is_send::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely + --> $DIR/not-send.rs:21:5 | - = help: within `std::marker::PhantomData<*const ()>`, the trait `std::marker::Send` is not implemented for `*const ()` - = note: required because it appears within the type `std::marker::PhantomData<*const ()>` - = note: required because of the requirements on the impl of `std::marker::Send` for `generic_array::GenericArray, typenum::uint::UInt, typenum::bit::B0>, typenum::bit::B0>>` - = note: required because it appears within the type `std::mem::ManuallyDrop, typenum::uint::UInt, typenum::bit::B0>, typenum::bit::B0>>>` - = note: required because it appears within the type `std::mem::MaybeUninit, typenum::uint::UInt, typenum::bit::B0>, typenum::bit::B0>>>` - = note: required because it appears within the type `heapless::i::Vec, typenum::uint::UInt, typenum::bit::B0>, typenum::bit::B0>>>` - = note: required because it appears within the type `heapless::vec::Vec, typenum::uint::UInt, typenum::bit::B0>, typenum::bit::B0>>` -note: required by `is_send` - --> $DIR/not-send.rs:12:1 +11 | fn is_send() + | ------- required by a bound in this +12 | where +13 | T: Send, + | ---- required by this bound in `is_send` +... +21 | is_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely | -12 | / fn is_send() -13 | | where -14 | | T: Send, -15 | | { -16 | | } - | |_^ + = help: within `heapless::Vec, 4_usize>`, the trait `Send` is not implemented for `*const ()` + = note: required because it appears within the type `PhantomData<*const ()>` + = note: required because it appears within the type `[PhantomData<*const ()>; 4]` + = note: required because it appears within the type `ManuallyDrop<[PhantomData<*const ()>; 4]>` + = note: required because it appears within the type `MaybeUninit<[PhantomData<*const ()>; 4]>` + = note: required because it appears within the type `heapless::Vec, 4_usize>` diff --git a/src/de.rs b/src/de.rs index 229a355ff8..73dcf0e4a3 100644 --- a/src/de.rs +++ b/src/de.rs @@ -1,10 +1,10 @@ +use crate::{ + sealed::binary_heap::Kind as BinaryHeapKind, BinaryHeap, IndexMap, IndexSet, LinearMap, String, + Vec, +}; use core::{fmt, marker::PhantomData}; use hash32::{BuildHasherDefault, Hash, Hasher}; use serde::de::{self, Deserialize, Deserializer, Error, MapAccess, SeqAccess}; -use crate::{ - sealed::binary_heap::Kind as BinaryHeapKind, - BinaryHeap, IndexMap, IndexSet, LinearMap, String, Vec, -}; // Sequential containers @@ -142,9 +142,9 @@ where where D: Deserializer<'de>, { - struct ValueVisitor<'de, K, V, S, const N:usize>(PhantomData<(&'de (), K, V, S)>); + struct ValueVisitor<'de, K, V, S, const N: usize>(PhantomData<(&'de (), K, V, S)>); - impl<'de, K, V, S, const N:usize> de::Visitor<'de> for ValueVisitor<'de, K, V, S, N> + impl<'de, K, V, S, const N: usize> de::Visitor<'de> for ValueVisitor<'de, K, V, S, N> where K: Eq + Hash + Deserialize<'de>, V: Deserialize<'de>, @@ -175,7 +175,7 @@ where } } -impl<'de, K, V, const N:usize> Deserialize<'de> for LinearMap +impl<'de, K, V, const N: usize> Deserialize<'de> for LinearMap where K: Eq + Deserialize<'de>, V: Deserialize<'de>, @@ -184,9 +184,9 @@ where where D: Deserializer<'de>, { - struct ValueVisitor<'de, K, V, const N:usize>(PhantomData<(&'de (), K, V)>); + struct ValueVisitor<'de, K, V, const N: usize>(PhantomData<(&'de (), K, V)>); - impl<'de, K, V, const N:usize> de::Visitor<'de> for ValueVisitor<'de, K, V, N> + impl<'de, K, V, const N: usize> de::Visitor<'de> for ValueVisitor<'de, K, V, N> where K: Eq + Deserialize<'de>, V: Deserialize<'de>, @@ -218,24 +218,18 @@ where // String containers -impl<'de, const N:usize> Deserialize<'de> for String -{ +impl<'de, const N: usize> Deserialize<'de> for String { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { - struct ValueVisitor<'de, const N:usize>(PhantomData<&'de ()>); + struct ValueVisitor<'de, const N: usize>(PhantomData<&'de ()>); - impl<'de, const N:usize > de::Visitor<'de> for ValueVisitor<'de, N> - { + impl<'de, const N: usize> de::Visitor<'de> for ValueVisitor<'de, N> { type Value = String; fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - write!( - formatter, - "a string no more than {} bytes long", - N as u64 - ) + write!(formatter, "a string no more than {} bytes long", N as u64) } fn visit_str(self, v: &str) -> Result diff --git a/src/indexmap.rs b/src/indexmap.rs index c2e5d459b6..6b4064a3e4 100644 --- a/src/indexmap.rs +++ b/src/indexmap.rs @@ -1,11 +1,4 @@ -use core::{ - borrow::Borrow, - fmt, - iter::FromIterator, - mem::{self, MaybeUninit}, - num::NonZeroU32, - ops, slice, -}; +use core::{borrow::Borrow, fmt, iter::FromIterator, mem, num::NonZeroU32, ops, slice}; use hash32::{BuildHasher, BuildHasherDefault, FnvHasher, Hash, Hasher}; @@ -126,14 +119,12 @@ macro_rules! probe_loop { } } -struct CoreMap -{ +struct CoreMap { entries: Vec, N>, indices: [Option; N], } -impl CoreMap -{ +impl CoreMap { const fn new() -> Self { const INIT: Option = None; diff --git a/src/pool/singleton.rs b/src/pool/singleton.rs index 17763df436..ccfa2de955 100644 --- a/src/pool/singleton.rs +++ b/src/pool/singleton.rs @@ -15,12 +15,14 @@ use as_slice::{AsMutSlice, AsSlice}; use super::{Init, Node, Uninit}; /// Instantiates a pool as a global singleton +// NOTE(any(test)) makes testing easier (no need to enable Cargo features for testing) #[cfg(any( armv7a, armv7r, armv7m, armv8m_main, all(target_arch = "x86_64", feature = "x86-sync-pool"), + test ))] #[macro_export] macro_rules! pool { diff --git a/src/ufmt.rs b/src/ufmt.rs index 84d87a4d23..30da99acd4 100644 --- a/src/ufmt.rs +++ b/src/ufmt.rs @@ -1,5 +1,5 @@ -use ufmt_write::uWrite; use crate::{string::String, vec::Vec}; +use ufmt_write::uWrite; impl uWrite for String { type Error = (); diff --git a/tests/cpass.rs b/tests/cpass.rs index 24b138e599..18d88d194b 100644 --- a/tests/cpass.rs +++ b/tests/cpass.rs @@ -1,7 +1,7 @@ //! Collections of `Send`-able things are `Send` use heapless::{ - spsc::{Consumer, Producer, Queue, MultiCore}, + spsc::{Consumer, MultiCore, Producer, Queue}, HistoryBuffer, Vec, }; diff --git a/tests/tsan.rs b/tests/tsan.rs index 6e9f264b38..9ea18add39 100644 --- a/tests/tsan.rs +++ b/tests/tsan.rs @@ -188,7 +188,7 @@ fn unchecked() { scope.execute(move || { let mut sum: usize = 0; - for _ in 0..N/ 2 { + for _ in 0..N / 2 { sum = sum.wrapping_add(usize::from(unsafe { c.dequeue_unchecked() })); } @@ -197,7 +197,7 @@ fn unchecked() { }); } - assert_eq!(rb.len(), N/ 2); + assert_eq!(rb.len(), N / 2); } #[test] @@ -235,6 +235,7 @@ fn iterator_properly_wraps() { assert_eq!(expected, actual) } +#[cfg(all(target_arch = "x86_64", feature = "x86-sync-pool"))] #[test] fn pool() { use heapless::pool::singleton::Pool as _;