Skip to content

Commit 723c328

Browse files
committed
Fix various CI errors
Fixes the following issues: - Failed to build on MSRV due to Unpin bound - Failed to build on no_std, as I didn't import Box - Failed to build on portable-atomic, as Arc didn't implement Unpin
1 parent e001c7a commit 723c328

File tree

5 files changed

+31
-27
lines changed

5 files changed

+31
-27
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ portable-atomic = ["portable-atomic-util", "portable_atomic_crate"]
2121

2222
[dependencies]
2323
parking = { version = "2.0.0", optional = true }
24-
portable-atomic-util = { version = "0.1.1", default-features = false, optional = true, features = ["alloc"] }
24+
portable-atomic-util = { version = "0.1.2", default-features = false, optional = true, features = ["alloc"] }
2525

2626
[dependencies.portable_atomic_crate]
2727
package = "portable-atomic"

src/lib.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ mod notify;
8080

8181
use alloc::boxed::Box;
8282

83+
use core::borrow::Borrow;
8384
use core::fmt;
8485
use core::future::Future;
8586
use core::marker::PhantomPinned;
8687
use core::mem::ManuallyDrop;
87-
use core::ops::Deref;
8888
use core::pin::Pin;
8989
use core::ptr;
9090
use core::task::{Context, Poll, Waker};
@@ -99,7 +99,7 @@ use sync::{Arc, WithMut};
9999

100100
pub use notify::{Additional, IntoNotification, Notification, Notify, Tag, TagWith};
101101

102-
/// Useful trait for listeners.
102+
/// Useful traits for notifications.
103103
pub mod prelude {
104104
pub use crate::{IntoNotification, Notification};
105105
}
@@ -129,7 +129,7 @@ struct Inner<T> {
129129
list: sys::List<T>,
130130
}
131131

132-
impl<T: Unpin> Inner<T> {
132+
impl<T> Inner<T> {
133133
fn new() -> Self {
134134
Self {
135135
notified: AtomicUsize::new(core::usize::MAX),
@@ -180,14 +180,14 @@ impl<T> fmt::Debug for Event<T> {
180180
}
181181
}
182182

183-
impl<T: Unpin> Default for Event<T> {
183+
impl<T> Default for Event<T> {
184184
#[inline]
185185
fn default() -> Self {
186186
Self::with_tag()
187187
}
188188
}
189189

190-
impl<T: Unpin> Event<T> {
190+
impl<T> Event<T> {
191191
/// Creates a new `Event` with a tag type.
192192
///
193193
/// # Examples
@@ -347,7 +347,7 @@ impl<T: Unpin> Event<T> {
347347

348348
if let Some(inner) = self.try_inner() {
349349
let limit = if notify.is_additional() {
350-
usize::MAX
350+
core::usize::MAX
351351
} else {
352352
notify.count()
353353
};
@@ -600,15 +600,15 @@ impl<T> Drop for Event<T> {
600600
/// If a notified listener is dropped without receiving a notification, dropping will notify
601601
/// another active listener. Whether one *additional* listener will be notified depends on what
602602
/// kind of notification was delivered.
603-
pub struct EventListener<T: Unpin = ()>(Listener<T, Arc<Inner<T>>>);
603+
pub struct EventListener<T = ()>(Listener<T, Arc<Inner<T>>>);
604604

605-
impl<T: Unpin> fmt::Debug for EventListener<T> {
605+
impl<T> fmt::Debug for EventListener<T> {
606606
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
607607
f.write_str("EventListener { .. }")
608608
}
609609
}
610610

611-
impl<T: Unpin> EventListener<T> {
611+
impl<T> EventListener<T> {
612612
/// Create a new `EventListener` that will wait for a notification from the given [`Event`].
613613
pub fn new(event: &Event<T>) -> Self {
614614
let inner = event.inner();
@@ -762,15 +762,15 @@ impl<T: Unpin> EventListener<T> {
762762
}
763763
}
764764

765-
impl<T: Unpin> Future for EventListener<T> {
765+
impl<T> Future for EventListener<T> {
766766
type Output = T;
767767

768768
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
769769
self.listener().poll_internal(cx)
770770
}
771771
}
772772

773-
struct Listener<T: Unpin, B: Deref<Target = Inner<T>> + Unpin> {
773+
struct Listener<T, B: Borrow<Inner<T>> + Unpin> {
774774
/// The reference to the original event.
775775
event: B,
776776

@@ -781,10 +781,10 @@ struct Listener<T: Unpin, B: Deref<Target = Inner<T>> + Unpin> {
781781
_pin: PhantomPinned,
782782
}
783783

784-
unsafe impl<T: Send + Unpin, B: Deref<Target = Inner<T>> + Unpin + Send> Send for Listener<T, B> {}
785-
unsafe impl<T: Send + Unpin, B: Deref<Target = Inner<T>> + Unpin + Sync> Sync for Listener<T, B> {}
784+
unsafe impl<T: Send, B: Borrow<Inner<T>> + Unpin + Send> Send for Listener<T, B> {}
785+
unsafe impl<T: Send, B: Borrow<Inner<T>> + Unpin + Sync> Sync for Listener<T, B> {}
786786

787-
impl<T: Unpin, B: Deref<Target = Inner<T>> + Unpin> Listener<T, B> {
787+
impl<T, B: Borrow<Inner<T>> + Unpin> Listener<T, B> {
788788
/// Pin-project this listener.
789789
fn project(self: Pin<&mut Self>) -> (&Inner<T>, Pin<&mut Option<sys::Listener<T>>>) {
790790
// SAFETY: `event` is `Unpin`, and `listener`'s pin status is preserved
@@ -793,7 +793,7 @@ impl<T: Unpin, B: Deref<Target = Inner<T>> + Unpin> Listener<T, B> {
793793
event, listener, ..
794794
} = self.get_unchecked_mut();
795795

796-
(&*event, Pin::new_unchecked(listener))
796+
((*event).borrow(), Pin::new_unchecked(listener))
797797
}
798798
}
799799

@@ -910,7 +910,7 @@ impl<T: Unpin, B: Deref<Target = Inner<T>> + Unpin> Listener<T, B> {
910910
}
911911
}
912912

913-
impl<T: Unpin, B: Deref<Target = Inner<T>> + Unpin> Drop for Listener<T, B> {
913+
impl<T, B: Borrow<Inner<T>> + Unpin> Drop for Listener<T, B> {
914914
fn drop(&mut self) {
915915
// If we're being dropped, we need to remove ourself from the list.
916916
let (inner, listener) = unsafe { Pin::new_unchecked(self).project() };
@@ -949,6 +949,7 @@ impl<T> State<T> {
949949
}
950950

951951
/// If this state was notified, return the tag associated with the notification.
952+
#[allow(unused)]
952953
fn notified(self) -> Option<T> {
953954
match self {
954955
Self::Notified { tag, .. } => Some(tag),

src/no_std.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ use core::num::NonZeroUsize;
3131
use core::ops;
3232
use core::pin::Pin;
3333

34+
use alloc::boxed::Box;
3435
use alloc::vec::Vec;
3536

36-
impl<T: Unpin> crate::Inner<T> {
37+
impl<T> crate::Inner<T> {
3738
/// Locks the list.
3839
fn try_lock(&self) -> Option<ListGuard<'_, T>> {
3940
self.list.inner.try_lock().map(|guard| ListGuard {
@@ -218,7 +219,7 @@ pub(crate) struct List<T> {
218219
queue: Queue<T>,
219220
}
220221

221-
impl<T: Unpin> List<T> {
222+
impl<T> List<T> {
222223
pub(super) fn new() -> List<T> {
223224
List {
224225
inner: Mutex::new(ListenerSlab::new()),
@@ -228,15 +229,15 @@ impl<T: Unpin> List<T> {
228229
}
229230

230231
/// The guard returned by [`Inner::lock`].
231-
pub(crate) struct ListGuard<'a, T: Unpin> {
232+
pub(crate) struct ListGuard<'a, T> {
232233
/// Reference to the inner state.
233234
pub(crate) inner: &'a crate::Inner<T>,
234235

235236
/// The locked list.
236237
pub(crate) guard: Option<MutexGuard<'a, ListenerSlab<T>>>,
237238
}
238239

239-
impl<T: Unpin> ListGuard<'_, T> {
240+
impl<T> ListGuard<'_, T> {
240241
#[cold]
241242
fn process_nodes_slow(
242243
&mut self,
@@ -254,21 +255,21 @@ impl<T: Unpin> ListGuard<'_, T> {
254255
}
255256
}
256257

257-
impl<T: Unpin> ops::Deref for ListGuard<'_, T> {
258+
impl<T> ops::Deref for ListGuard<'_, T> {
258259
type Target = ListenerSlab<T>;
259260

260261
fn deref(&self) -> &Self::Target {
261262
self.guard.as_ref().unwrap()
262263
}
263264
}
264265

265-
impl<T: Unpin> ops::DerefMut for ListGuard<'_, T> {
266+
impl<T> ops::DerefMut for ListGuard<'_, T> {
266267
fn deref_mut(&mut self) -> &mut Self::Target {
267268
self.guard.as_mut().unwrap()
268269
}
269270
}
270271

271-
impl<T: Unpin> Drop for ListGuard<'_, T> {
272+
impl<T> Drop for ListGuard<'_, T> {
272273
fn drop(&mut self) {
273274
let Self { inner, guard } = self;
274275
let mut list = guard.take().unwrap();
@@ -443,7 +444,7 @@ pub(crate) struct ListenerSlab<T> {
443444
first_empty: NonZeroUsize,
444445
}
445446

446-
impl<T: Unpin> ListenerSlab<T> {
447+
impl<T> ListenerSlab<T> {
447448
/// Create a new, empty list.
448449
pub(crate) fn new() -> Self {
449450
Self {
@@ -665,6 +666,8 @@ pub(crate) enum Listener<T> {
665666
_EatLifetime(PhantomData<T>),
666667
}
667668

669+
impl<T> Unpin for Listener<T> {}
670+
668671
impl<T> PartialEq for Listener<T> {
669672
fn eq(&self, other: &Self) -> bool {
670673
match (self, other) {

src/no_std/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub(crate) struct TaskWaiting {
5252
entry_id: AtomicUsize,
5353
}
5454

55-
impl<T: Unpin> Node<T> {
55+
impl<T> Node<T> {
5656
pub(crate) fn listener() -> (Self, Arc<TaskWaiting>) {
5757
// Create a new `TaskWaiting` structure.
5858
let task_waiting = Arc::new(TaskWaiting {

src/notify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ macro_rules! impl_for_numeric_types {
323323
type Tag = ();
324324
type Notify = Notify;
325325

326+
#[allow(unused_comparisons)]
326327
fn into_notification(self) -> Self::Notify {
327-
#[allow(unused_comparisons)]
328328
if self < 0 {
329329
panic!("negative notification count");
330330
}

0 commit comments

Comments
 (0)