Skip to content

Commit ec157cc

Browse files
committed
Apply clippy fixes, except in #[test] code
1 parent 91e83b7 commit ec157cc

File tree

31 files changed

+101
-95
lines changed

31 files changed

+101
-95
lines changed

.github/workflows/CI.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ jobs:
4848
command: fmt
4949
args: --all -- --check
5050

51+
- name: cargo clippy
52+
uses: actions-rs/cargo@v1
53+
with:
54+
command: clippy
55+
args: --features full --lib --examples --benches
56+
5157
test:
5258
name: Test ${{ matrix.rust }} on ${{ matrix.os }}
5359
needs: [style]

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

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

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

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/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> {

examples/upgrades.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ async fn main() {
160160
res = &mut conn => {
161161
if let Err(err) = res {
162162
println!("Error serving connection: {:?}", err);
163-
return;
164163
}
165164
}
166165
// Continue polling the connection after enabling graceful shutdown.
@@ -178,7 +177,7 @@ async fn main() {
178177
});
179178

180179
// Client requests a HTTP connection upgrade.
181-
let request = client_upgrade_request(addr.clone());
180+
let request = client_upgrade_request(addr);
182181
if let Err(e) = request.await {
183182
eprintln!("client error: {}", e);
184183
}

0 commit comments

Comments
 (0)