From 5e66561085613dbd67ae36ea5b82622bea64ca3d Mon Sep 17 00:00:00 2001 From: Oliver Rockstedt Date: Mon, 7 Oct 2024 11:22:01 +0200 Subject: [PATCH 1/4] Rustdoc clippy and typo fixes --- src/indexmap.rs | 2 +- src/mpmc.rs | 4 ++-- src/spsc.rs | 4 ++-- src/string/mod.rs | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/indexmap.rs b/src/indexmap.rs index 80efe62e73..05f1ae10c6 100644 --- a/src/indexmap.rs +++ b/src/indexmap.rs @@ -1125,7 +1125,7 @@ where /// Remove the key-value pair equivalent to `key` and return its value. /// /// Like `Vec::swap_remove`, the pair is removed by swapping it with the last element of the map - /// and popping it off. **This perturbs the postion of what used to be the last element!** + /// and popping it off. **This perturbs the position of what used to be the last element!** /// /// Return `None` if `key` is not in map. /// diff --git a/src/mpmc.rs b/src/mpmc.rs index caef2caf9d..a685816b6f 100644 --- a/src/mpmc.rs +++ b/src/mpmc.rs @@ -67,10 +67,10 @@ //! not. //! - All execution times are in clock cycles. 1 clock cycle = 125 ns. //! - Execution time is *dependent* of `mem::size_of::()`. Both operations include one -//! `memcpy(T)` in their successful path. +//! `memcpy(T)` in their successful path. //! - The optimization level is indicated in parentheses. //! - The numbers reported correspond to the successful path (i.e. `Some` is returned by `dequeue` -//! and `Ok` is returned by `enqueue`). +//! and `Ok` is returned by `enqueue`). //! //! # Portability //! diff --git a/src/spsc.rs b/src/spsc.rs index 5311a7897e..471d0598d5 100644 --- a/src/spsc.rs +++ b/src/spsc.rs @@ -92,10 +92,10 @@ //! //! - All execution times are in clock cycles. 1 clock cycle = 125 ns. //! - Execution time is *dependent* of `mem::size_of::()`. Both operations include one -//! `memcpy(T)` in their successful path. +//! `memcpy(T)` in their successful path. //! - The optimization level is indicated in the first row. //! - The numbers reported correspond to the successful path (i.e. `Some` is returned by `dequeue` -//! and `Ok` is returned by `enqueue`). +//! and `Ok` is returned by `enqueue`). use core::{borrow::Borrow, cell::UnsafeCell, fmt, hash, mem::MaybeUninit, ptr}; diff --git a/src/string/mod.rs b/src/string/mod.rs index d88dbf0fd0..44c9c1559b 100644 --- a/src/string/mod.rs +++ b/src/string/mod.rs @@ -852,9 +852,9 @@ pub fn format(args: Arguments<'_>) -> Result, fmt::Err /// There are two possible error cases. Both return the unit type [`core::fmt::Error`]. /// /// - In case the formatting exceeds the string's capacity. This error does not exist in -/// the standard library as the string would just grow. +/// the standard library as the string would just grow. /// - If a formatting trait implementation returns an error. The standard library panics -/// in this case. +/// in this case. /// /// # Examples /// @@ -1102,7 +1102,7 @@ mod tests { match s.pop() { Some(c) => { assert_eq!(s.len(), 1); - assert_eq!(c, '\u{0301}'); // accute accent of e + assert_eq!(c, '\u{0301}'); // acute accent of e } None => panic!(), }; From dda9d7c1dad7b36f8d12d79c74b85d3857467dfb Mon Sep 17 00:00:00 2001 From: Oliver Rockstedt Date: Mon, 7 Oct 2024 15:00:13 +0200 Subject: [PATCH 2/4] Fix for remaining clippy warnings --- src/mpmc.rs | 4 +--- src/spsc.rs | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/mpmc.rs b/src/mpmc.rs index a685816b6f..7c90d1f562 100644 --- a/src/mpmc.rs +++ b/src/mpmc.rs @@ -151,8 +151,6 @@ pub type MpMcQueue = MpMcQueueInner>; pub type MpMcQueueView = MpMcQueueInner; impl MpMcQueue { - const EMPTY_CELL: Cell = Cell::new(0); - const ASSERT: [(); 1] = [()]; /// Creates an empty queue @@ -167,7 +165,7 @@ impl MpMcQueue { let mut cell_count = 0; - let mut result_cells: [Cell; N] = [Self::EMPTY_CELL; N]; + let mut result_cells: [Cell; N] = [const { Cell::new(0) }; N]; while cell_count != N { result_cells[cell_count] = Cell::new(cell_count); cell_count += 1; diff --git a/src/spsc.rs b/src/spsc.rs index 471d0598d5..9ebcb996ab 100644 --- a/src/spsc.rs +++ b/src/spsc.rs @@ -135,7 +135,6 @@ pub type Queue = QueueInner>; pub type QueueView = QueueInner; impl Queue { - const INIT: UnsafeCell> = UnsafeCell::new(MaybeUninit::uninit()); /// Creates an empty queue with a fixed capacity of `N - 1` pub const fn new() -> Self { // Const assert N > 1 @@ -144,7 +143,7 @@ impl Queue { Queue { head: AtomicUsize::new(0), tail: AtomicUsize::new(0), - buffer: [Self::INIT; N], + buffer: [const { UnsafeCell::new(MaybeUninit::uninit()) }; N], } } From 184adc7f54b94de45ceeb4ea4a898303543cbd4d Mon Sep 17 00:00:00 2001 From: Oliver Rockstedt Date: Mon, 7 Oct 2024 15:04:19 +0200 Subject: [PATCH 3/4] Another fix for remaining clippy warnings --- src/pool.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pool.rs b/src/pool.rs index 03c19dd92c..71e06ade9b 100644 --- a/src/pool.rs +++ b/src/pool.rs @@ -5,7 +5,7 @@ //! This module/API is only available on these compilation targets: //! //! - ARM architectures which instruction set include the LDREX, CLREX and STREX instructions, e.g. -//! `thumbv7m-none-eabi` but not `thumbv6m-none-eabi` +//! `thumbv7m-none-eabi` but not `thumbv6m-none-eabi` //! - 32-bit x86, e.g. `i686-unknown-linux-gnu` //! //! # Benchmarks @@ -37,8 +37,8 @@ //! ``` //! //! - measurement method: the cycle counter (CYCCNT) register was sampled each time a breakpoint -//! (`bkpt`) was hit. the difference between the "after" and the "before" value of CYCCNT yields the -//! execution time in clock cycles. +//! (`bkpt`) was hit. the difference between the "after" and the "before" value of CYCCNT yields the +//! execution time in clock cycles. //! //! | API | clock cycles | //! |------------------------------|--------------| From d9012250d3c10c36dc8fc836654aaabffb60b342 Mon Sep 17 00:00:00 2001 From: Oliver Rockstedt Date: Mon, 7 Oct 2024 15:16:58 +0200 Subject: [PATCH 4/4] Fix for clippy warning in tests --- src/string/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/string/mod.rs b/src/string/mod.rs index 44c9c1559b..6dfe2055dc 100644 --- a/src/string/mod.rs +++ b/src/string/mod.rs @@ -1027,7 +1027,7 @@ mod tests { let s: String<4> = String::try_from("ab").unwrap(); let b: Vec = s.into_bytes(); assert_eq!(b.len(), 2); - assert_eq!(&[b'a', b'b'], &b[..]); + assert_eq!(b"ab", &b[..]); } #[test]