Skip to content

Commit

Permalink
Run clippy on the test suite
Browse files Browse the repository at this point in the history
This makes sure that we're not responsible for Clippy triggering in the
user's code.

Not sure whether Clippy is *supposed* to trigger in macro output, but it
is what it is.

To run clippy on the test suite we need to use the --all --all-targets
flags, which have a side effect of Clippy finding the benches/ directory
even though it has been commented out in Cargo.toml. This means we can
no longer keep the criterion dev-dependency commented out.
  • Loading branch information
meithecatte committed Dec 26, 2021
1 parent 8d9e3ef commit a4b96e4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
toolchain: nightly
override: true
components: clippy
- run: cargo clippy -- -D warnings
- run: cargo clippy --all --all-targets -- -D warnings
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ optional = true
[features]
std = []

#[dev-dependencies]
#criterion = "0.3"
#
#[[bench]]
#name = "from_iterator"
#harness = false
#path = "benches/from_iterator.rs"
[dev-dependencies]
criterion = "0.3"

[[bench]]
name = "from_iterator"
harness = false
path = "benches/from_iterator.rs"

[workspace]
members = [
Expand Down
12 changes: 6 additions & 6 deletions test_suite/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn iterator() {
];

for &(bitflag, expected) in tests {
assert!(bitflag.iter().zip(expected.iter().cloned()).all(|(a, b)| a == b));
assert!(bitflag.iter().zip(expected.iter().copied()).all(|(a, b)| a == b));
// If cloned, the iterator will yield the same elements.
let it = bitflag.iter();
assert!(it.clone().zip(it).all(|(a, b)| a == b));
Expand All @@ -109,7 +109,7 @@ fn assign_ops() {
}

#[test]
fn fn_derive() {
const fn fn_derive() {
#[bitflags]
#[derive(Copy, Clone, Debug)]
#[repr(u8)]
Expand All @@ -119,7 +119,7 @@ fn fn_derive() {
}

#[test]
fn module() {
const fn module() {
mod some_modules {
#[enumflags2::bitflags]
#[derive(Copy, Clone, Debug)]
Expand All @@ -145,9 +145,6 @@ fn inferred_values() {
SpecifiedB = 4,
}

assert_eq!(Inferred::Infer2 as u8, 2);
assert_eq!(Inferred::Infer8 as u8, 8);

#[bitflags]
#[derive(Copy, Clone, Debug)]
#[repr(u8)]
Expand All @@ -158,6 +155,9 @@ fn inferred_values() {
Infer8,
}

assert_eq!(Inferred::Infer2 as u8, 2);
assert_eq!(Inferred::Infer8 as u8, 8);

assert_eq!(OnlyInferred::Infer1 as u8, 1);
assert_eq!(OnlyInferred::Infer2 as u8, 2);
assert_eq!(OnlyInferred::Infer4 as u8, 4);
Expand Down
9 changes: 7 additions & 2 deletions test_suite/tests/bitflag_tests_2018.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
use enumflags2::bitflags;
// "an inner attribute is not permitted in this context" :/
#[deny(clippy::all, clippy::pedantic, clippy::nursery)]
mod everything {

include!("../common.rs");
use enumflags2::bitflags;

include!("../common.rs");
}

0 comments on commit a4b96e4

Please sign in to comment.