Skip to content

Commit

Permalink
Merge #765
Browse files Browse the repository at this point in the history
765: Apply clippy to tests and examples r=taiki-e a=taiki-e

I intentionally allow some lint for the same reason as described in #696.

Co-authored-by: Taiki Endo <te316e89@gmail.com>
  • Loading branch information
bors[bot] and taiki-e committed Jan 8, 2022
2 parents c6bda10 + 6937f96 commit 46a4d60
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 33 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ defaults:
jobs:
# Test crates on their minimum Rust versions and nightly Rust.
test:
name: test
env:
RUST_VERSION: ${{ matrix.rust }}
RUST_TARGET: ${{ matrix.target }}
Expand Down Expand Up @@ -60,7 +59,6 @@ jobs:

# Check all feature combinations works properly.
features:
name: features
env:
RUST_VERSION: ${{ matrix.rust }}
strategy:
Expand All @@ -80,7 +78,6 @@ jobs:

# Check for duplicate dependencies.
dependencies:
name: dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -105,7 +102,6 @@ jobs:

# Check formatting.
rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -116,7 +112,6 @@ jobs:

# Check clippy.
clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -127,16 +122,16 @@ jobs:

# Run miri.
miri:
name: miri
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust
run: rustup toolchain install nightly --component miri && rustup default nightly
- name: miri
run: ./ci/miri.sh

# Run sanitizers.
san:
name: san
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -147,7 +142,6 @@ jobs:

# Run loom tests.
loom:
name: loom
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -158,7 +152,6 @@ jobs:

# Check if the document can be generated without warning.
docs:
name: docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion ci/clippy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set -ex

rustup component add clippy

cargo clippy --all
cargo clippy --all --tests --examples
5 changes: 0 additions & 5 deletions ci/miri.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
cd "$(dirname "$0")"/..
set -ex

toolchain=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)
rustup set profile minimal
rustup default "$toolchain"
rustup component add miri

MIRIFLAGS="-Zmiri-tag-raw-pointers" \
cargo miri test \
-p crossbeam-queue
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/benches/crossbeam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod unbounded {

#[bench]
fn create(b: &mut Bencher) {
b.iter(|| unbounded::<i32>());
b.iter(unbounded::<i32>);
}

#[bench]
Expand Down
6 changes: 3 additions & 3 deletions crossbeam-channel/tests/golang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//! - https://golang.org/LICENSE
//! - https://golang.org/PATENTS

#![allow(clippy::mutex_atomic, clippy::redundant_clone)]

use std::alloc::{GlobalAlloc, Layout, System};
use std::any::Any;
use std::cell::Cell;
Expand Down Expand Up @@ -710,9 +712,7 @@ mod select2 {
fn receiver(c: &Chan<i32>, dummy: &Chan<i32>, n: i32) {
for _ in 0..n {
select! {
recv(c.rx()) -> _ => {
()
}
recv(c.rx()) -> _ => {}
recv(dummy.rx()) -> _ => {
panic!("dummy");
}
Expand Down
16 changes: 8 additions & 8 deletions crossbeam-channel/tests/mpsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
//! - https://github.com/rust-lang/rust/blob/master/COPYRIGHT
//! - https://www.rust-lang.org/en-US/legal.html

#![allow(
clippy::drop_copy,
clippy::match_single_binding,
clippy::redundant_clone
)]

use std::sync::mpsc::{RecvError, RecvTimeoutError, TryRecvError};
use std::sync::mpsc::{SendError, TrySendError};
use std::thread::JoinHandle;
Expand Down Expand Up @@ -344,10 +350,7 @@ mod channel_tests {
for _ in 0..AMT * NTHREADS {
assert_eq!(rx.recv().unwrap(), 1);
}
match rx.try_recv() {
Ok(..) => panic!(),
_ => {}
}
assert!(rx.try_recv().is_err());
});

let mut ts = Vec::with_capacity(NTHREADS as usize);
Expand Down Expand Up @@ -1203,10 +1206,7 @@ mod sync_channel_tests {
for _ in 0..AMT * NTHREADS {
assert_eq!(rx.recv().unwrap(), 1);
}
match rx.try_recv() {
Ok(..) => panic!(),
_ => {}
}
assert!(rx.try_recv().is_err());
dtx.send(()).unwrap();
});

Expand Down
2 changes: 2 additions & 0 deletions crossbeam-channel/tests/ready.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Tests for channel readiness using the `Select` struct.

#![allow(clippy::drop_copy)]

use std::any::Any;
use std::cell::Cell;
use std::thread;
Expand Down
2 changes: 2 additions & 0 deletions crossbeam-channel/tests/select.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Tests for channel selection using the `Select` struct.

#![allow(clippy::drop_copy)]

use std::any::Any;
use std::cell::Cell;
use std::thread;
Expand Down
3 changes: 3 additions & 0 deletions crossbeam-channel/tests/select_macro.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Tests for the `select!` macro.

#![forbid(unsafe_code)] // select! is safe.
#![allow(clippy::drop_copy, clippy::match_single_binding)]

use std::any::Any;
use std::cell::Cell;
Expand Down Expand Up @@ -943,6 +944,7 @@ fn fairness_send() {
assert!(hits.iter().all(|x| *x >= COUNT / 4));
}

#[allow(clippy::or_fun_call)] // This is intentional.
#[test]
fn references() {
let (s, r) = unbounded::<i32>();
Expand Down Expand Up @@ -989,6 +991,7 @@ fn case_blocks() {
drop(s);
}

#[allow(clippy::redundant_closure_call)] // This is intentional.
#[test]
fn move_handles() {
let (s, r) = unbounded::<i32>();
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-deque/tests/fifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ fn destructors() {
{
let mut v = dropped.lock().unwrap();
assert_eq!(v.len(), rem);
v.sort();
v.sort_unstable();
for pair in v.windows(2) {
assert_eq!(pair[0] + 1, pair[1]);
}
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-deque/tests/injector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ fn destructors() {
{
let mut v = dropped.lock().unwrap();
assert_eq!(v.len(), rem);
v.sort();
v.sort_unstable();
for pair in v.windows(2) {
assert_eq!(pair[0] + 1, pair[1]);
}
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-deque/tests/lifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ fn destructors() {
{
let mut v = dropped.lock().unwrap();
assert_eq!(v.len(), rem);
v.sort();
v.sort_unstable();
for pair in v.windows(2) {
assert_eq!(pair[0] + 1, pair[1]);
}
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-epoch/benches/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use test::Bencher;

#[bench]
fn single_pin(b: &mut Bencher) {
b.iter(|| epoch::pin());
b.iter(epoch::pin);
}

#[bench]
Expand Down
2 changes: 2 additions & 0 deletions crossbeam-epoch/src/deferred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ impl Deferred {

#[cfg(all(test, not(crossbeam_loom)))]
mod tests {
#![allow(clippy::drop_copy)]

use super::Deferred;
use std::cell::Cell;

Expand Down
4 changes: 2 additions & 2 deletions crossbeam-epoch/src/sync/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ mod test {

let mut vl2 = vl.clone();
let mut vr2 = vr.clone();
vl2.sort();
vr2.sort();
vl2.sort_unstable();
vr2.sort_unstable();

assert_eq!(vl, vl2);
assert_eq!(vr, vr2);
Expand Down
2 changes: 2 additions & 0 deletions crossbeam-skiplist/tests/base.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::mutex_atomic, clippy::redundant_clone)]

use std::ops::Bound;
use std::sync::atomic::{AtomicUsize, Ordering};

Expand Down
2 changes: 2 additions & 0 deletions crossbeam-skiplist/tests/map.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::mutex_atomic)]

use std::{iter, ops::Bound, sync::Barrier};

use crossbeam_skiplist::SkipMap;
Expand Down

0 comments on commit 46a4d60

Please sign in to comment.