From 148c4b3cc0cf02dde54cd0f32f5a61e0acaea895 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 18 Nov 2025 17:24:52 +0100 Subject: [PATCH] fix the const assertion for the queue size --- rtic-sync/src/channel.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rtic-sync/src/channel.rs b/rtic-sync/src/channel.rs index fe536085e16..aa05de65842 100644 --- a/rtic-sync/src/channel.rs +++ b/rtic-sync/src/channel.rs @@ -72,11 +72,17 @@ impl Default for Channel { } impl Channel { - const _CHECK: () = assert!(N < 256, "This queue support a maximum of 255 entries"); + // Size check. + const fn size_check() { + // This limit comes from the the internal `Deque` structures used to track free and ready + // slots which have a type of [u8] + assert!(N < 256, "This queue support a maximum of 255 entries"); + } /// Create a new channel. #[cfg(not(loom))] pub const fn new() -> Self { + Self::size_check(); Self { freeq: UnsafeCell::new(Deque::new()), readyq: UnsafeCell::new(Deque::new()), @@ -91,6 +97,7 @@ impl Channel { /// Create a new channel. #[cfg(loom)] pub fn new() -> Self { + Self::size_check(); Self { freeq: UnsafeCell::new(Deque::new()), readyq: UnsafeCell::new(Deque::new()),