style(lib): address most clippy lints

This commit is contained in:
danieleades
2020-01-03 17:40:32 +00:00
committed by Sean McArthur
parent 0f13719873
commit 0eaf304644
29 changed files with 162 additions and 200 deletions

View File

@@ -310,7 +310,7 @@ macro_rules! __client_req_header {
}
}
static REPLY_OK: &'static str = "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n";
static REPLY_OK: &str = "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n";
test! {
name: client_get,
@@ -1771,7 +1771,7 @@ mod dispatch_impl {
// so the unwrapped responses futures show it still worked.
assert_eq!(connects.load(Ordering::SeqCst), 3);
let res4 = client.get(url.clone());
let res4 = client.get(url);
rt.block_on(res4).unwrap();
assert_eq!(
@@ -1800,8 +1800,8 @@ mod dispatch_impl {
fn with_http_and_closes(http: HttpConnector, closes: mpsc::Sender<()>) -> DebugConnector {
DebugConnector {
http: http,
closes: closes,
http,
closes,
connects: Arc::new(AtomicUsize::new(0)),
is_proxy: false,
alpn_h2: false,
@@ -2242,7 +2242,7 @@ mod conn {
let tcp = rt.block_on(tcp_connect(&addr)).unwrap();
let io = DebugStream {
tcp: tcp,
tcp,
shutdown_called: false,
};
@@ -2330,7 +2330,7 @@ mod conn {
let tcp = rt.block_on(tcp_connect(&addr)).unwrap();
let io = DebugStream {
tcp: tcp,
tcp,
shutdown_called: false,
};

View File

@@ -1457,7 +1457,7 @@ async fn max_buf_size() {
thread::spawn(move || {
let mut tcp = connect(&addr);
tcp.write_all(b"POST /").expect("write 1");
tcp.write_all(&vec![b'a'; MAX]).expect("write 2");
tcp.write_all(&[b'a'; MAX]).expect("write 2");
let mut buf = [0; 256];
tcp.read(&mut buf).expect("read 1");
@@ -1481,8 +1481,8 @@ fn streaming_body() {
// disable keep-alive so we can use read_to_end
let server = serve_opts().keep_alive(false).serve();
static S: &'static [&'static [u8]] = &[&[b'x'; 1_000] as &[u8]; 1_00] as _;
let b = ::futures_util::stream::iter(S.into_iter()).map(|&s| Ok::<_, hyper::Error>(s));
static S: &[&[u8]] = &[&[b'x'; 1_000] as &[u8]; 1_00] as _;
let b = futures_util::stream::iter(S.iter()).map(|&s| Ok::<_, hyper::Error>(s));
let b = hyper::Body::wrap_stream(b);
server.reply().body_stream(b);
@@ -1588,7 +1588,7 @@ fn http2_body_user_error_sends_reset_reason() {
let server = serve();
let addr_str = format!("http://{}", server.addr());
let b = ::futures_util::stream::once(future::err::<String, _>(h2::Error::from(
let b = futures_util::stream::once(future::err::<String, _>(h2::Error::from(
h2::Reason::INADEQUATE_SECURITY,
)));
let b = hyper::Body::wrap_stream(b);
@@ -1931,7 +1931,7 @@ impl TestService {
}
}
const HELLO: &'static str = "hello";
const HELLO: &str = "hello";
struct HelloWorld;
@@ -2030,8 +2030,8 @@ impl ServeOptions {
let msg_tx = msg_tx.clone();
let reply_rx = reply_rx.clone();
future::ok::<_, BoxError>(TestService {
tx: msg_tx.clone(),
reply: reply_rx.clone(),
tx: msg_tx,
reply: reply_rx,
})
});
@@ -2056,9 +2056,9 @@ impl ServeOptions {
let addr = addr_rx.recv().expect("server addr rx");
Serve {
msg_rx: msg_rx,
msg_rx,
reply_tx: Mutex::new(reply_tx),
addr: addr,
addr,
shutdown_signal: Some(shutdown_tx),
thread: Some(thread),
}

View File

@@ -375,7 +375,7 @@ async fn async_test(cfg: __TestConfig) {
let mut addr = server.local_addr();
tokio::task::spawn(server.map(|result| {
let _ = result.expect("server error");
result.expect("server error");
}));
if cfg.proxy {
@@ -460,7 +460,7 @@ fn naive_proxy(cfg: ProxyConfig) -> (SocketAddr, impl Future<Output = ()>) {
let srv = Server::bind(&([127, 0, 0, 1], 0).into()).serve(make_service_fn(move |_| {
let prev = counter.fetch_add(1, Ordering::Relaxed);
assert!(max_connections >= prev + 1, "proxy max connections");
assert!(max_connections > prev, "proxy max connections");
let client = client.clone();
future::ok::<_, hyper::Error>(service_fn(move |mut req| {
let uri = format!("http://{}{}", dst_addr, req.uri().path())