Skip to content

Commit

Permalink
chore: Fix lints (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb authored Sep 12, 2024
1 parent cc249b2 commit 8717b76
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/barrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl EventListenerFuture for BarrierWaitInner<'_> {
// We are the last one.
state.count = 0;
state.generation_id = state.generation_id.wrapping_add(1);
this.barrier.event.notify(core::usize::MAX);
this.barrier.event.notify(usize::MAX);
return Poll::Ready(BarrierWaitResult { is_leader: true });
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use core::marker::{PhantomData, PhantomPinned};
use core::ops::{Deref, DerefMut};
use core::pin::Pin;
use core::task::Poll;
use core::usize;

use alloc::sync::Arc;

Expand Down Expand Up @@ -314,7 +313,7 @@ impl<T> From<T> for Mutex<T> {
}
}

impl<T: Default + ?Sized> Default for Mutex<T> {
impl<T: Default> Default for Mutex<T> {
fn default() -> Mutex<T> {
Mutex::new(Default::default())
}
Expand Down
9 changes: 7 additions & 2 deletions src/once_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ impl<T> OnceCell<T> {
/// # });
/// ```
pub async fn get_or_init<Fut: Future<Output = T>>(&self, closure: impl FnOnce() -> Fut) -> &T {
// false positive: https://github.com/rust-lang/rust/issues/129352
#[allow(unreachable_patterns)]
match self
.get_or_try_init(move || async move {
let result: Result<T, Infallible> = Ok(closure().await);
Expand Down Expand Up @@ -517,6 +519,9 @@ impl<T> OnceCell<T> {
let result: Result<T, Infallible> = Ok(closure());
result
});

// false positive: https://github.com/rust-lang/rust/issues/129352
#[allow(unreachable_patterns)]
match result {
Ok(value) => value,
Err(infallible) => match infallible {},
Expand Down Expand Up @@ -659,8 +664,8 @@ impl<T> OnceCell<T> {
.store(State::Initialized.into(), Ordering::Release);

// Notify the listeners that the value is initialized.
self.active_initializers.notify_additional(core::usize::MAX);
self.passive_waiters.notify_additional(core::usize::MAX);
self.active_initializers.notify_additional(usize::MAX);
self.passive_waiters.notify_additional(usize::MAX);

return Ok(());
}
Expand Down
2 changes: 1 addition & 1 deletion src/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ impl<T> From<T> for RwLock<T> {
}
}

impl<T: Default + ?Sized> Default for RwLock<T> {
impl<T: Default> Default for RwLock<T> {
#[inline]
fn default() -> RwLock<T> {
RwLock::new(Default::default())
Expand Down
8 changes: 4 additions & 4 deletions src/rwlock/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl RawRwLock {
}

// Make sure the number of readers doesn't overflow.
if state > core::isize::MAX as usize {
if state > isize::MAX as usize {
crate::abort();
}

Expand Down Expand Up @@ -111,7 +111,7 @@ impl RawRwLock {
let mut state = self.state.load(Ordering::Acquire);

// Make sure the number of readers doesn't overflow.
if state > core::isize::MAX as usize {
if state > isize::MAX as usize {
crate::abort();
}

Expand Down Expand Up @@ -320,7 +320,7 @@ impl<'a> EventListenerFuture for RawRead<'a> {
loop {
if *this.state & WRITER_BIT == 0 {
// Make sure the number of readers doesn't overflow.
if *this.state > core::isize::MAX as usize {
if *this.state > isize::MAX as usize {
crate::abort();
}

Expand Down Expand Up @@ -390,7 +390,7 @@ impl<'a> EventListenerFuture for RawUpgradableRead<'a> {
let mut state = this.lock.state.load(Ordering::Acquire);

// Make sure the number of readers doesn't overflow.
if state > core::isize::MAX as usize {
if state > isize::MAX as usize {
crate::abort();
}

Expand Down

0 comments on commit 8717b76

Please sign in to comment.