Skip to content

Commit 907e6f9

Browse files
committed
Apply clippy fixes, except in #[test] code
1 parent 0888623 commit 907e6f9

File tree

33 files changed

+108
-103
lines changed

33 files changed

+108
-103
lines changed

.github/workflows/CI.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ jobs:
8282
uses: actions-rs/toolchain@v1
8383
with:
8484
profile: minimal
85+
components: clippy
8586
toolchain: ${{ matrix.rust }}
8687
override: true
8788

@@ -91,6 +92,12 @@ jobs:
9192
command: test
9293
args: ${{ matrix.features }}
9394

95+
- name: Clippy
96+
uses: actions-rs/cargo@v1
97+
with:
98+
command: clippy
99+
args: ${{ matrix.features }} --lib --examples --benches
100+
94101
- name: Test all benches
95102
if: matrix.benches
96103
uses: actions-rs/cargo@v1

benches/body.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(feature = "nightly")]
12
#![feature(test)]
23
#![deny(warnings)]
34

benches/connect.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
#![cfg(feature = "nightly")]
12
#![feature(test)]
23
#![deny(warnings)]
34

4-
extern crate test;
5-
65
// TODO: Reimplement http_connector bench using hyper::client::conn
76
// (instead of removed HttpConnector).
87

benches/end_to_end.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
#![cfg(feature = "nightly")]
12
#![feature(test)]
23
#![deny(warnings)]
34

4-
extern crate test;
5-
65
// TODO: Reimplement Opts::bench using hyper::server::conn and hyper::client::conn
76
// (instead of Server and HttpClient).
87

benches/pipeline.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(feature = "nightly")]
12
#![feature(test)]
23
#![deny(warnings)]
34

benches/server.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(feature = "nightly")]
12
#![feature(test)]
23
#![deny(warnings)]
34

@@ -149,7 +150,7 @@ fn raw_tcp_throughput_small_payload(b: &mut test::Bencher) {
149150

150151
let mut buf = [0u8; 8192];
151152
while rx.try_recv().is_err() {
152-
sock.read(&mut buf).unwrap();
153+
let _ = sock.read(&mut buf).unwrap();
153154
sock.write_all(
154155
b"\
155156
HTTP/1.1 200 OK\r\n\
@@ -196,7 +197,7 @@ fn raw_tcp_throughput_large_payload(b: &mut test::Bencher) {
196197
let mut buf = [0u8; 8192];
197198
while rx.try_recv().is_err() {
198199
let r = sock.read(&mut buf).unwrap();
199-
extern crate test;
200+
200201
if r == 0 {
201202
break;
202203
}

benches/support/tokiort.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ impl Timer for TokioTimer {
3232
fn sleep(&self, duration: Duration) -> Box<dyn Sleep + Unpin> {
3333
let s = tokio::time::sleep(duration);
3434
let hs = TokioSleep { inner: Box::pin(s) };
35-
return Box::new(hs);
35+
Box::new(hs)
3636
}
3737

3838
fn sleep_until(&self, deadline: Instant) -> Box<dyn Sleep + Unpin> {
39-
return Box::new(TokioSleep {
39+
Box::new(TokioSleep {
4040
inner: Box::pin(tokio::time::sleep_until(deadline.into())),
41-
});
41+
})
4242
}
4343
}
4444

examples/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ async fn fetch_url(url: hyper::Uri) -> Result<()> {
6565
while let Some(next) = res.frame().await {
6666
let frame = next?;
6767
if let Some(chunk) = frame.data_ref() {
68-
io::stdout().write_all(&chunk).await?;
68+
io::stdout().write_all(chunk).await?;
6969
}
7070
}
7171

examples/gateway.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
1111
let in_addr: SocketAddr = ([127, 0, 0, 1], 3001).into();
1212
let out_addr: SocketAddr = ([127, 0, 0, 1], 3000).into();
1313

14-
let out_addr_clone = out_addr.clone();
15-
1614
let listener = TcpListener::bind(in_addr).await?;
1715

1816
println!("Listening on http://{}", in_addr);
@@ -27,7 +25,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2725
let service = service_fn(move |mut req| {
2826
let uri_string = format!(
2927
"http://{}{}",
30-
out_addr_clone,
28+
out_addr,
3129
req.uri()
3230
.path_and_query()
3331
.map(|x| x.as_str())

examples/http_proxy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ async fn proxy(req: Request<Recv>) -> Result<Response<BoxBody<Bytes, hyper::Erro
104104
}
105105

106106
fn host_addr(uri: &http::Uri) -> Option<String> {
107-
uri.authority().and_then(|auth| Some(auth.to_string()))
107+
uri.authority().map(|auth| auth.to_string())
108108
}
109109

110110
fn empty() -> BoxBody<Bytes, hyper::Error> {

0 commit comments

Comments
 (0)