Skip to content

Commit

Permalink
Add lint rules and fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mirromutth committed Dec 19, 2023
1 parent da3c57b commit cb270a5
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 14 deletions.
7 changes: 7 additions & 0 deletions benches/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#![cfg(feature = "comparison")]
#![deny(
missing_debug_implementations,
rust_2018_idioms,
unreachable_pub,
elided_lifetimes_in_paths,
clippy::missing_const_for_fn
)]

pub mod async_std;
pub mod mutex;
Expand Down
8 changes: 6 additions & 2 deletions latches/src/futex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,12 @@ impl Latch {
self.stat.load(Acquire)
}

/// Checks that the current counter has reached 0 and return [`Ok(())`],
/// otherwise return [`Err(count)`].
/// Checks that the current counter has reached 0.
///
/// # Errors
///
/// This function will return an error with the current count if the
/// counter has not reached 0.
///
/// # Examples
///
Expand Down
6 changes: 5 additions & 1 deletion latches/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
missing_docs,
rust_2018_idioms,
unreachable_pub,
elided_lifetimes_in_paths
elided_lifetimes_in_paths,
clippy::missing_const_for_fn,
clippy::missing_panics_doc,
clippy::missing_safety_doc,
clippy::missing_errors_doc
)]
#![doc(test(no_crate_inject, attr(deny(warnings, rust_2018_idioms))))]
#![cfg_attr(docsrs, feature(doc_cfg))]
Expand Down
8 changes: 6 additions & 2 deletions latches/src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,12 @@ impl Latch {
self.stat.load(Acquire)
}

/// Checks that the current counter has reached 0 and return [`Ok(())`],
/// otherwise return [`Err(count)`].
/// Checks that the current counter has reached 0.
///
/// # Errors
///
/// This function will return an error with the current count if the
/// counter has not reached 0.
///
/// # Examples
///
Expand Down
12 changes: 8 additions & 4 deletions latches/src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,12 @@ impl Latch {
self.stat.load(Acquire)
}

/// Checks that the counter has reached 0 and return [`Ok(())`], otherwise
/// return [`Err(count)`].
/// Checks that the counter has reached 0.
///
/// # Errors
///
/// This function will return an error with the current count if the
/// counter has not reached 0.
///
/// # Examples
///
Expand Down Expand Up @@ -262,7 +266,7 @@ impl Latch {
/// # });
/// ```
#[inline]
pub fn wait(&self) -> LatchWait<'_> {
pub const fn wait(&self) -> LatchWait<'_> {
LatchWait {
id: None,
latch: self,
Expand Down Expand Up @@ -341,7 +345,7 @@ impl Latch {
/// # });
/// ```
#[inline]
pub fn watch<T>(&self, timer: T) -> LatchWatch<'_, T> {
pub const fn watch<T>(&self, timer: T) -> LatchWatch<'_, T> {
LatchWatch {
id: None,
latch: self,
Expand Down
2 changes: 1 addition & 1 deletion latches/src/task/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ unsafe fn v_c(ptr: *const ()) -> RawWaker {
unsafe fn wake(ptr: *const ()) {
(*(ptr as *const AtomicU32)).fetch_add(1, Ordering::Relaxed);
}
unsafe fn noop(_: *const ()) {}
const unsafe fn noop(_: *const ()) {}

fn new_waker(data: Pin<&AtomicU32>) -> Waker {
unsafe {
Expand Down
2 changes: 1 addition & 1 deletion latches/src/task/waiters/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ unsafe fn v_c(ptr: *const ()) -> RawWaker {
unsafe fn wake(ptr: *const ()) {
(*(ptr as *const AtomicU32)).fetch_add(1, Ordering::Relaxed);
}
unsafe fn noop(_: *const ()) {}
const unsafe fn noop(_: *const ()) {}

fn new_waker(data: Pin<&AtomicU32>) -> Waker {
unsafe {
Expand Down
14 changes: 12 additions & 2 deletions latches/src/timeout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<T> WaitTimeoutResult<T> {
/// ```
#[must_use]
#[inline]
pub fn is_reached(&self) -> bool {
pub const fn is_reached(&self) -> bool {
matches!(self, WaitTimeoutResult::Reached)
}

Expand All @@ -49,7 +49,7 @@ impl<T> WaitTimeoutResult<T> {
/// ```
#[must_use]
#[inline]
pub fn is_timed_out(&self) -> bool {
pub const fn is_timed_out(&self) -> bool {
matches!(self, WaitTimeoutResult::TimedOut(_))
}

Expand Down Expand Up @@ -87,6 +87,11 @@ impl<T> WaitTimeoutResult<T> {
/// result of a function call, it is recommended to use [`ok_by`], which
/// is lazily evaluated.
///
/// # Errors
///
/// This function will return an error with the content of [`TimedOut(t)`]
/// if it is timed out.
///
/// [`Ok(v)`]: Ok
/// [`Err(t)`]: Err
/// [`Reached`]: WaitTimeoutResult::Reached
Expand Down Expand Up @@ -120,6 +125,11 @@ impl<T> WaitTimeoutResult<T> {
/// [`Reached`]: WaitTimeoutResult::Reached
/// [`TimedOut(t)`]: WaitTimeoutResult::TimedOut
///
/// # Errors
///
/// This function will return an error with the content of [`TimedOut(t)`]
/// if it is timed out.
///
/// # Examples
///
/// ```
Expand Down
2 changes: 1 addition & 1 deletion latches/src/timeout/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn test_ok() {

#[test]
fn test_ok_by() {
fn lazy_one() -> i32 {
const fn lazy_one() -> i32 {
1
}

Expand Down

0 comments on commit cb270a5

Please sign in to comment.