Skip to content

Commit 724c00f

Browse files
committed
Apply clippy fixes, except in #[test] code
1 parent 0766d3f commit 724c00f

File tree

29 files changed

+99
-102
lines changed

29 files changed

+99
-102
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/connect.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#![feature(test)]
22
#![deny(warnings)]
33

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

benches/end_to_end.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#![feature(test)]
22
#![deny(warnings)]
33

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

benches/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn raw_tcp_throughput_small_payload(b: &mut test::Bencher) {
148148

149149
let mut buf = [0u8; 8192];
150150
while rx.try_recv().is_err() {
151-
sock.read(&mut buf).unwrap();
151+
let _ = sock.read(&mut buf).unwrap();
152152
sock.write_all(
153153
b"\
154154
HTTP/1.1 200 OK\r\n\
@@ -195,7 +195,7 @@ fn raw_tcp_throughput_large_payload(b: &mut test::Bencher) {
195195
let mut buf = [0u8; 8192];
196196
while rx.try_recv().is_err() {
197197
let r = sock.read(&mut buf).unwrap();
198-
extern crate test;
198+
199199
if r == 0 {
200200
break;
201201
}

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
}

examples/web_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ async fn main() -> Result<()> {
111111
let (stream, _) = listener.accept().await?;
112112

113113
tokio::task::spawn(async move {
114-
let service = service_fn(move |req| response_examples(req));
114+
let service = service_fn(response_examples);
115115

116116
if let Err(err) = http1::Builder::new()
117117
.serve_connection(stream, service)

src/body/body.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,11 @@ impl Recv {
130130
if !content_length.is_exact() && recv.is_end_stream() {
131131
content_length = DecodedLength::ZERO;
132132
}
133-
let body = Recv::new(Kind::H2 {
133+
Recv::new(Kind::H2 {
134134
ping,
135135
content_length,
136136
recv,
137-
});
138-
139-
body
137+
})
140138
}
141139

142140
#[cfg(feature = "ffi")]
@@ -350,6 +348,7 @@ impl Sender {
350348

351349
/// Aborts the body in an abnormal fashion.
352350
#[allow(unused)]
351+
#[allow(clippy::redundant_clone)]
353352
pub(crate) fn abort(self) {
354353
let _ = self
355354
.data_tx

0 commit comments

Comments
 (0)