diff --git a/crossbeam-channel/examples/fibonacci.rs b/crossbeam-channel/examples/fibonacci.rs index cf22b7a57..e6f5e89c0 100644 --- a/crossbeam-channel/examples/fibonacci.rs +++ b/crossbeam-channel/examples/fibonacci.rs @@ -10,7 +10,7 @@ fn fibonacci(sender: Sender) { while sender.send(x).is_ok() { let tmp = x; x = y; - y = tmp + y; + y += tmp; } } diff --git a/crossbeam-channel/examples/stopwatch.rs b/crossbeam-channel/examples/stopwatch.rs index 98895c5a3..3a7578e00 100644 --- a/crossbeam-channel/examples/stopwatch.rs +++ b/crossbeam-channel/examples/stopwatch.rs @@ -33,11 +33,7 @@ fn main() { // Prints the elapsed time. fn show(dur: Duration) { - println!( - "Elapsed: {}.{:03} sec", - dur.as_secs(), - dur.subsec_nanos() / 1_000_000 - ); + println!("Elapsed: {}.{:03} sec", dur.as_secs(), dur.subsec_millis()); } let start = Instant::now(); diff --git a/crossbeam-channel/tests/golang.rs b/crossbeam-channel/tests/golang.rs index cd7001326..afd07baf9 100644 --- a/crossbeam-channel/tests/golang.rs +++ b/crossbeam-channel/tests/golang.rs @@ -176,7 +176,7 @@ unsafe impl GlobalAlloc for Counter { if !ret.is_null() { ALLOCATED.fetch_add(layout.size(), SeqCst); } - return ret; + ret } unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { diff --git a/crossbeam-deque/tests/fifo.rs b/crossbeam-deque/tests/fifo.rs index f86fbd1b8..e2365fb91 100644 --- a/crossbeam-deque/tests/fifo.rs +++ b/crossbeam-deque/tests/fifo.rs @@ -167,7 +167,7 @@ fn stress() { hits.fetch_add(1, SeqCst); } - while let Some(_) = w2.pop() { + while w2.pop().is_some() { hits.fetch_add(1, SeqCst); } } @@ -178,7 +178,7 @@ fn stress() { let mut expected = 0; while expected < COUNT { if rng.gen_range(0..3) == 0 { - while let Some(_) = w.pop() { + while w.pop().is_some() { hits.fetch_add(1, SeqCst); } } else { @@ -188,7 +188,7 @@ fn stress() { } while hits.load(SeqCst) < COUNT { - while let Some(_) = w.pop() { + while w.pop().is_some() { hits.fetch_add(1, SeqCst); } } @@ -227,7 +227,7 @@ fn no_starvation() { hits.fetch_add(1, SeqCst); } - while let Some(_) = w2.pop() { + while w2.pop().is_some() { hits.fetch_add(1, SeqCst); } } @@ -239,7 +239,7 @@ fn no_starvation() { loop { for i in 0..rng.gen_range(0..COUNT) { if rng.gen_range(0..3) == 0 && my_hits == 0 { - while let Some(_) = w.pop() { + while w.pop().is_some() { my_hits += 1; } } else { @@ -300,7 +300,7 @@ fn destructors() { remaining.fetch_sub(1, SeqCst); } - while let Some(_) = w2.pop() { + while w2.pop().is_some() { cnt += 1; remaining.fetch_sub(1, SeqCst); } @@ -309,7 +309,7 @@ fn destructors() { } for _ in 0..STEPS { - if let Some(_) = w.pop() { + if w.pop().is_some() { remaining.fetch_sub(1, SeqCst); } } diff --git a/crossbeam-deque/tests/injector.rs b/crossbeam-deque/tests/injector.rs index fb2298340..3f74d1bfb 100644 --- a/crossbeam-deque/tests/injector.rs +++ b/crossbeam-deque/tests/injector.rs @@ -178,7 +178,7 @@ fn stress() { hits.fetch_add(1, SeqCst); } - while let Some(_) = w2.pop() { + while w2.pop().is_some() { hits.fetch_add(1, SeqCst); } } @@ -238,7 +238,7 @@ fn no_starvation() { hits.fetch_add(1, SeqCst); } - while let Some(_) = w2.pop() { + while w2.pop().is_some() { hits.fetch_add(1, SeqCst); } } @@ -311,7 +311,7 @@ fn destructors() { remaining.fetch_sub(1, SeqCst); } - while let Some(_) = w2.pop() { + while w2.pop().is_some() { cnt += 1; remaining.fetch_sub(1, SeqCst); } diff --git a/crossbeam-deque/tests/lifo.rs b/crossbeam-deque/tests/lifo.rs index 8681db0dc..3e99e95c5 100644 --- a/crossbeam-deque/tests/lifo.rs +++ b/crossbeam-deque/tests/lifo.rs @@ -167,7 +167,7 @@ fn stress() { hits.fetch_add(1, SeqCst); } - while let Some(_) = w2.pop() { + while w2.pop().is_some() { hits.fetch_add(1, SeqCst); } } @@ -178,7 +178,7 @@ fn stress() { let mut expected = 0; while expected < COUNT { if rng.gen_range(0..3) == 0 { - while let Some(_) = w.pop() { + while w.pop().is_some() { hits.fetch_add(1, SeqCst); } } else { @@ -188,7 +188,7 @@ fn stress() { } while hits.load(SeqCst) < COUNT { - while let Some(_) = w.pop() { + while w.pop().is_some() { hits.fetch_add(1, SeqCst); } } @@ -227,7 +227,7 @@ fn no_starvation() { hits.fetch_add(1, SeqCst); } - while let Some(_) = w2.pop() { + while w2.pop().is_some() { hits.fetch_add(1, SeqCst); } } @@ -239,7 +239,7 @@ fn no_starvation() { loop { for i in 0..rng.gen_range(0..COUNT) { if rng.gen_range(0..3) == 0 && my_hits == 0 { - while let Some(_) = w.pop() { + while w.pop().is_some() { my_hits += 1; } } else { @@ -300,7 +300,7 @@ fn destructors() { remaining.fetch_sub(1, SeqCst); } - while let Some(_) = w2.pop() { + while w2.pop().is_some() { cnt += 1; remaining.fetch_sub(1, SeqCst); } @@ -309,7 +309,7 @@ fn destructors() { } for _ in 0..STEPS { - if let Some(_) = w.pop() { + if w.pop().is_some() { remaining.fetch_sub(1, SeqCst); } } diff --git a/crossbeam-epoch/src/atomic.rs b/crossbeam-epoch/src/atomic.rs index 75a4714ef..a1bf1c5b8 100644 --- a/crossbeam-epoch/src/atomic.rs +++ b/crossbeam-epoch/src/atomic.rs @@ -1545,6 +1545,6 @@ mod tests { #[test] fn const_atomic_null() { use super::Atomic; - const _: Atomic = Atomic::::null(); + static _U: Atomic = Atomic::::null(); } } diff --git a/crossbeam-skiplist/tests/base.rs b/crossbeam-skiplist/tests/base.rs index 520344dd3..f08e1409e 100644 --- a/crossbeam-skiplist/tests/base.rs +++ b/crossbeam-skiplist/tests/base.rs @@ -164,7 +164,7 @@ fn len() { assert_eq!(s.len(), 0); for (i, &x) in [4, 2, 12, 8, 7, 11, 5].iter().enumerate() { - s.insert(x, x * 1, guard); + s.insert(x, x * 10, guard); assert_eq!(s.len(), i + 1); } diff --git a/crossbeam-utils/tests/cache_padded.rs b/crossbeam-utils/tests/cache_padded.rs index c9e768771..86e9a7709 100644 --- a/crossbeam-utils/tests/cache_padded.rs +++ b/crossbeam-utils/tests/cache_padded.rs @@ -85,6 +85,7 @@ fn drops() { assert_eq!(count.get(), 2); } +#[allow(clippy::clone_on_copy)] // This is intentional. #[test] fn clone() { let a = CachePadded::new(17); diff --git a/crossbeam-utils/tests/sharded_lock.rs b/crossbeam-utils/tests/sharded_lock.rs index c36215440..b46d64a76 100644 --- a/crossbeam-utils/tests/sharded_lock.rs +++ b/crossbeam-utils/tests/sharded_lock.rs @@ -138,7 +138,7 @@ fn arc() { fn arc_access_in_unwind() { let arc = Arc::new(ShardedLock::new(1)); let arc2 = arc.clone(); - let _ = thread::spawn(move || -> () { + let _ = thread::spawn(move || { struct Unwinder { i: Arc>, }