Skip to content

Commit a4b96e4

Browse files
committed
Run clippy on the test suite
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.
1 parent 8d9e3ef commit a4b96e4

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
toolchain: nightly
3434
override: true
3535
components: clippy
36-
- run: cargo clippy -- -D warnings
36+
- run: cargo clippy --all --all-targets -- -D warnings

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ optional = true
2323
[features]
2424
std = []
2525

26-
#[dev-dependencies]
27-
#criterion = "0.3"
28-
#
29-
#[[bench]]
30-
#name = "from_iterator"
31-
#harness = false
32-
#path = "benches/from_iterator.rs"
26+
[dev-dependencies]
27+
criterion = "0.3"
28+
29+
[[bench]]
30+
name = "from_iterator"
31+
harness = false
32+
path = "benches/from_iterator.rs"
3333

3434
[workspace]
3535
members = [

test_suite/common.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fn iterator() {
8686
];
8787

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

111111
#[test]
112-
fn fn_derive() {
112+
const fn fn_derive() {
113113
#[bitflags]
114114
#[derive(Copy, Clone, Debug)]
115115
#[repr(u8)]
@@ -119,7 +119,7 @@ fn fn_derive() {
119119
}
120120

121121
#[test]
122-
fn module() {
122+
const fn module() {
123123
mod some_modules {
124124
#[enumflags2::bitflags]
125125
#[derive(Copy, Clone, Debug)]
@@ -145,9 +145,6 @@ fn inferred_values() {
145145
SpecifiedB = 4,
146146
}
147147

148-
assert_eq!(Inferred::Infer2 as u8, 2);
149-
assert_eq!(Inferred::Infer8 as u8, 8);
150-
151148
#[bitflags]
152149
#[derive(Copy, Clone, Debug)]
153150
#[repr(u8)]
@@ -158,6 +155,9 @@ fn inferred_values() {
158155
Infer8,
159156
}
160157

158+
assert_eq!(Inferred::Infer2 as u8, 2);
159+
assert_eq!(Inferred::Infer8 as u8, 8);
160+
161161
assert_eq!(OnlyInferred::Infer1 as u8, 1);
162162
assert_eq!(OnlyInferred::Infer2 as u8, 2);
163163
assert_eq!(OnlyInferred::Infer4 as u8, 4);
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
use enumflags2::bitflags;
1+
// "an inner attribute is not permitted in this context" :/
2+
#[deny(clippy::all, clippy::pedantic, clippy::nursery)]
3+
mod everything {
24

3-
include!("../common.rs");
5+
use enumflags2::bitflags;
6+
7+
include!("../common.rs");
8+
}

0 commit comments

Comments
 (0)