Skip to content

Commit 3d7feb2

Browse files
authored
chore: fix clippy warnings, modernize CI (#212)
1 parent 3614726 commit 3d7feb2

File tree

5 files changed

+39
-115
lines changed

5 files changed

+39
-115
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -48,32 +48,22 @@ jobs:
4848

4949
steps:
5050
- name: Checkout
51-
uses: actions/checkout@v1
51+
uses: actions/checkout@v5
5252

5353
- name: Install Rust (${{ matrix.rust }})
54-
uses: actions-rs/toolchain@v1
54+
uses: dtolnay/rust-toolchain@master
5555
with:
56-
profile: minimal
5756
toolchain: ${{ matrix.rust }}
58-
override: true
5957

6058
- name: no_std
61-
uses: actions-rs/cargo@v1
62-
with:
63-
command: build
64-
args: --no-default-features
59+
run: cargo build --no-default-features
6560

6661
- name: Test
67-
uses: actions-rs/cargo@v1
68-
with:
69-
command: test
62+
run: cargo test
7063

7164
- name: Test all benches
7265
if: matrix.benches
73-
uses: actions-rs/cargo@v1
74-
with:
75-
command: test
76-
args: --benches
66+
run: cargo test --benches
7767

7868
simd:
7969
name: SIMD ${{ matrix.target_feature }} on ${{ matrix.rust }}
@@ -96,105 +86,82 @@ jobs:
9686

9787
steps:
9888
- name: Checkout
99-
uses: actions/checkout@v1
89+
uses: actions/checkout@v5
10090

10191
- name: Install Rust (${{ matrix.rust }})
102-
uses: actions-rs/toolchain@v1
92+
uses: dtolnay/rust-toolchain@master
10393
with:
104-
profile: minimal
10594
toolchain: ${{ matrix.rust }}
106-
override: true
10795

10896
- name: Test
109-
uses: actions-rs/cargo@v1
110-
with:
111-
command: test
11297
env:
11398
RUSTFLAGS: -C target_feature=${{ matrix.target_feature }}
11499
CARGO_CFG_HTTPARSE_DISABLE_SIMD_COMPILETIME: ${{ matrix.disable_compiletime }}
100+
run: cargo test
115101

116102
check_x86:
117103
name: check x86
118104
runs-on: ubuntu-latest
119105
steps:
120106
- name: Checkout
121-
uses: actions/checkout@v1
107+
uses: actions/checkout@v5
122108

123109
- name: Setup Rust
124-
uses: actions-rs/toolchain@v1
110+
uses: dtolnay/rust-toolchain@stable
125111
with:
126-
profile: minimal
127-
toolchain: stable
128-
override: true
129-
target: i686-unknown-linux-musl
112+
targets: i686-unknown-linux-musl
130113

131114
- name: Test without SIMD
132-
uses: actions-rs/cargo@v1
133-
with:
134-
command: test
135-
args: --target i686-unknown-linux-musl
136115
env:
137116
CARGO_CFG_HTTPARSE_DISABLE_SIMD_COMPILETIME: 1
117+
run: cargo test --target i686-unknown-linux-musl
138118

139119
- name: Test
140-
141-
uses: actions-rs/cargo@v1
142-
with:
143-
command: test
144-
args: --target i686-unknown-linux-musl
120+
run: cargo test --target i686-unknown-linux-musl
145121

146122
msrv_x64:
147123
name: msrv (x64)
148124
runs-on: ubuntu-latest
149125
steps:
150126
- name: Checkout
151-
uses: actions/checkout@v1
127+
uses: actions/checkout@v5
152128

153129
- name: Install Rust
154-
uses: actions-rs/toolchain@v1
155-
with:
156-
profile: minimal
157-
toolchain: 1.47.0
158-
override: true
130+
uses: dtolnay/rust-toolchain@1.47.0
159131

160132
# Only build, dev-dependencies don't compile on 1.47.0
161133
- name: Build
162-
uses: actions-rs/cargo@v1
163-
with:
164-
command: build
134+
run: cargo build
165135

166136
# This tests that aarch64 gracefully fallbacks to SWAR if neon_intrinsics aren't available (<1.59)
167137
msrv_aarch64:
168138
name: msrv (aarch64)
169139
runs-on: ubuntu-latest
170140
steps:
171141
- name: Checkout
172-
uses: actions/checkout@v1
142+
uses: actions/checkout@v5
173143

174144
- name: Install cross-compiling dependencies
175145
run: |
176146
sudo apt-get update
177147
sudo apt-get install -y gcc-aarch64-linux-gnu
178148
179149
- name: Setup Rust
180-
uses: actions-rs/toolchain@v1
150+
uses: dtolnay/rust-toolchain@1.47.0
181151
with:
182-
profile: minimal
183-
toolchain: 1.47.0
184-
override: true
185152
target: aarch64-unknown-linux-gnu
186153

187154
# Only build, dev-dependencies don't compile on 1.47.0
188155
- name: Build
189-
uses: actions-rs/cargo@v1
190-
with:
191-
command: build
192-
args: --target aarch64-unknown-linux-gnu
156+
run: cargo build --target aarch64-unknown-linux-gnu
193157

194158
clippy_check:
195159
runs-on: ubuntu-latest
196160
steps:
197-
- uses: actions/checkout@v3
161+
- uses: actions/checkout@v5
162+
- uses: dtolnay/rust-toolchain@stable
163+
with:
164+
components: clippy
198165
- name: Run clippy
199166
run: cargo clippy --all-targets --all-features
200167

@@ -204,43 +171,15 @@ jobs:
204171

205172
steps:
206173
- name: Checkout
207-
uses: actions/checkout@v1
174+
uses: actions/checkout@v5
208175

209176
- name: Install Rust
210-
uses: actions-rs/toolchain@v1
177+
uses: dtolnay/rust-toolchain@nightly
211178
with:
212-
profile: minimal
213-
toolchain: nightly
214179
components: miri
215-
override: true
216180

217181
- name: Test
218182
run: cargo miri test
219-
#
220-
# mirai:
221-
# name: MIRAI static analysis
222-
# runs-on: ubuntu-latest
223-
#
224-
# steps:
225-
# - name: Checkout
226-
# uses: actions/checkout@v1
227-
#
228-
# - name: Install Rust
229-
# uses: actions-rs/toolchain@v1
230-
# with:
231-
# profile: minimal
232-
# toolchain: nightly-2023-05-09
233-
# components: clippy, rustfmt, rustc-dev, rust-src, rust-std, llvm-tools-preview
234-
# override: true
235-
#
236-
# - name: install mirai
237-
# run: cargo install --locked --git https://github.com/facebookexperimental/MIRAI/ mirai
238-
# env:
239-
# # MIRAI_FLAGS: --diag=(default|verify|library|paranoid)
240-
# MIRAI_FLAGS: --diag=default
241-
#
242-
# - name: cargo mirai
243-
# run: cargo mirai --lib
244183

245184
aarch64:
246185
name: Test aarch64 (neon)
@@ -249,15 +188,12 @@ jobs:
249188
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
250189
steps:
251190
- name: Checkout repository
252-
uses: actions/checkout@v2
191+
uses: actions/checkout@v5
253192

254193
- name: Setup Rust
255-
uses: actions-rs/toolchain@v1
194+
uses: dtolnay/rust-toolchain@stable
256195
with:
257-
profile: minimal
258-
toolchain: stable
259-
override: true
260-
target: aarch64-unknown-linux-gnu
196+
targets: aarch64-unknown-linux-gnu
261197

262198
- name: Install QEMU and dependencies
263199
run: |

.github/workflows/cibench.yml

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,12 @@ jobs:
1212
name: Run benchmarks
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v5
1616
with:
1717
fetch-depth: 0
1818

1919
- name: Install Rust
20-
uses: actions-rs/toolchain@v1
21-
with:
22-
profile: minimal
23-
toolchain: stable
24-
override: true
20+
uses: dtolnay/rust-toolchain@stable
2521

2622
- name: Install critcmp
2723
run: cargo install critcmp
@@ -47,16 +43,12 @@ jobs:
4743
matrix:
4844
feature: [swar, sse42, avx2]
4945
steps:
50-
- uses: actions/checkout@v3
46+
- uses: actions/checkout@v5
5147
with:
5248
fetch-depth: 0
5349

5450
- name: Install Rust
55-
uses: actions-rs/toolchain@v1
56-
with:
57-
profile: minimal
58-
toolchain: stable
59-
override: true
51+
uses: dtolnay/rust-toolchain@stable
6052

6153
- name: Install critcmp
6254
run: cargo install critcmp
@@ -88,16 +80,12 @@ jobs:
8880
matrix:
8981
feature: [swar, neon]
9082
steps:
91-
- uses: actions/checkout@v3
83+
- uses: actions/checkout@v5
9284
with:
9385
fetch-depth: 0
9486

9587
- name: Install Rust
96-
uses: actions-rs/toolchain@v1
97-
with:
98-
profile: minimal
99-
toolchain: stable
100-
override: true
88+
uses: dtolnay/rust-toolchain@stable
10189

10290
- name: Install critcmp
10391
run: cargo install critcmp

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ default = ["std"]
1717
std = []
1818

1919
[dev-dependencies]
20-
criterion = "0.3.5"
20+
criterion = { version = "0.3.5", features = ["html_reports"] }
2121
rand = "0.8.5"
2222

2323
[lib]

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg_attr(not(feature = "std"), no_std)]
1+
#![cfg_attr(not(any(test, feature = "std")), no_std)]
22
#![deny(
33
missing_docs,
44
clippy::missing_safety_doc,
@@ -1795,7 +1795,7 @@ mod tests {
17951795
let mut headers = [EMPTY_HEADER; NUM_OF_HEADERS];
17961796
let mut req = Request::new(&mut headers[..]);
17971797
for i in 0..req_str.len() {
1798-
let status = req.parse(req_str[..i].as_bytes());
1798+
let status = req.parse(&req_str.as_bytes()[..i]);
17991799
assert_eq!(
18001800
status,
18011801
Ok(Status::Partial),

src/simd/neon.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ unsafe fn offsetnz(x: uint8x16_t) -> u32 {
182182
if low != 0 {
183183
clz(low)
184184
} else if high != 0 {
185-
return 8 + clz(high);
185+
8 + clz(high)
186186
} else {
187-
return 16;
187+
16
188188
}
189189
}
190190

0 commit comments

Comments
 (0)