Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix lints #92

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)]
taiki-e marked this conversation as resolved.
Show resolved Hide resolved
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)]
jayvdb marked this conversation as resolved.
Show resolved Hide resolved
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
Loading