Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy #26

Merged
merged 4 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntex-h2"
version = "0.5.0"
version = "0.5.1"
license = "MIT OR Apache-2.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "An HTTP/2 client and server"
Expand All @@ -10,7 +10,7 @@ readme = "README.md"
keywords = ["http", "async", "non-blocking"]
categories = ["asynchronous", "web-programming", "network-programming"]
exclude = ["fixtures/**", "util/**", "fuzz/**"]
edition = "2018"
edition = "2021"

[features]
default = []
Expand Down Expand Up @@ -46,13 +46,13 @@ walkdir = "2.3.2"
serde = "1.0.0"
serde_json = "1.0.0"

ntex = { version = "1.0.0-b.0", features = ["openssl", "tokio"] }
ntex-tls = { version = "1.0.0", features = ["openssl"] }
ntex = { version = "1.1", features = ["openssl", "tokio"] }
ntex-tls = { version = "1.0", features = ["openssl"] }
openssl = "0.10"

# Examples
env_logger = { version = "0.10", default-features = false }
ntex-connect = { version = "1.0.0", features = ["openssl", "tokio"] }
env_logger = { version = "0.11", default-features = false }
ntex-connect = { version = "1.0", features = ["openssl", "tokio"] }

[patch.crates-io]
ntex-h2 = { path = "." }
2 changes: 1 addition & 1 deletion examples/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{convert::TryFrom, error::Error};
use std::error::Error;

use ntex_bytes::Bytes;
use ntex_connect as connect;
Expand Down
2 changes: 0 additions & 2 deletions examples/server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::convert::TryFrom;

use ntex::service::fn_service;
use ntex_h2::{server, ControlMessage, Message, MessageKind, OperationError};
use ntex_http::{header, HeaderMap, StatusCode};
Expand Down
2 changes: 0 additions & 2 deletions examples/tls-server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::convert::TryFrom;

use ntex::service::{fn_service, ServiceFactory};
use ntex_h2::{server, ControlMessage, Message, MessageKind, OperationError};
use ntex_http::{header, HeaderMap, StatusCode};
Expand Down
2 changes: 1 addition & 1 deletion src/client/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Client {
let (tx, rx) = oneshot::channel();
let inner = self.inner.clone();
let waiters = self.waiters.clone();
ntex_rt::spawn(async move {
let _ = ntex_rt::spawn(async move {
let res = match timeout_checked(inner.conn_timeout, (*inner.connector)()).await
{
Ok(Ok(io)) => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl SimpleClient {
disp,
&con.config().dispatcher_config,
);
ntex_rt::spawn(async move {
let _ = ntex_rt::spawn(async move {
let _ = fut.await;
});

Expand Down
5 changes: 2 additions & 3 deletions src/client/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ impl Inflight {
}
}

#[allow(dead_code)]
#[derive(Debug)]
/// Send part of the client stream
pub struct SendStream(StreamRef, InflightStorage);
pub struct SendStream(StreamRef, ());

impl Drop for SendStream {
fn drop(&mut self) {
Expand Down Expand Up @@ -237,7 +236,7 @@ impl InflightStorage {

pub(super) fn inflight(&self, stream: Stream) -> (SendStream, RecvStream) {
let id = stream.id();
let snd = SendStream(stream.clone(), self.clone());
let snd = SendStream(stream.clone(), ());
let rcv = RecvStream(stream.clone(), self.clone());
let inflight = Inflight {
_stream: stream,
Expand Down
4 changes: 2 additions & 2 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Connection {

// start ping/pong
if con.0.local_config.0.ping_timeout.get().non_zero() {
spawn(ping(
let _ = spawn(ping(
con.clone(),
con.0.local_config.0.ping_timeout.get(),
io,
Expand Down Expand Up @@ -363,7 +363,7 @@ impl Connection {
ids.insert(id);
queue.push_back((id, now() + self.0.local_config.0.reset_duration.get()));
if !flags.contains(ConnectionFlags::DELAY_DROP_TASK_STARTED) {
spawn(delay_drop_task(self.clone()));
let _ = spawn(delay_drop_task(self.clone()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ where
fn handle_connection_error(&self, streams: HashMap<StreamId, StreamRef>, err: OperationError) {
if !streams.is_empty() {
let inner = self.inner.clone();
spawn(async move {
let _ = spawn(async move {
let p = Pipeline::new(&inner.publish);
let futs = streams
.into_values()
Expand Down
3 changes: 1 addition & 2 deletions src/hpack/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,6 @@ pub fn get_static(idx: usize) -> Header {
#[cfg(test)]
mod test {
use super::*;
use crate::hpack::Header;

#[test]
fn test_peek_u8() {
Expand Down Expand Up @@ -903,7 +902,7 @@ mod test {
let value = huff_encode(b"bar");
let mut buf = BytesMut::new();
// header name is non_huff encoded
buf.extend(&[0b01000000, 0x00 | 3]);
buf.extend(&[0b01000000, 3]);
buf.extend(b"foo");
// header value is partial
buf.extend(&[0x80 | 3]);
Expand Down
1 change: 0 additions & 1 deletion src/hpack/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ mod test {
use ntex_http::*;

use super::*;
use crate::hpack::Header;

#[test]
fn test_encode_method_get() {
Expand Down
1 change: 0 additions & 1 deletion src/hpack/header.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![allow(clippy::len_without_is_empty)]
use std::convert::TryFrom;

use ntex_bytes::{ByteString, Bytes};
use ntex_http::{HeaderName, HeaderValue, Method, StatusCode};
Expand Down
4 changes: 2 additions & 2 deletions src/hpack/huffman/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ mod test {
#[test]
fn decode_single_byte() {
assert_eq!("o", decode(&[0b00111111]).unwrap());
assert_eq!("0", decode(&[0x0 + 7]).unwrap());
assert_eq!("0", decode(&[7]).unwrap());
assert_eq!("A", decode(&[(0x21 << 2) + 3]).unwrap());
}

Expand All @@ -138,7 +138,7 @@ mod test {

dst.clear();
encode(b"0", &mut dst);
assert_eq!(&dst[..], &[0x0 + 7]);
assert_eq!(&dst[..], &[7]);

dst.clear();
encode(b"A", &mut dst);
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@

#![cfg_attr(test, deny(warnings))]
#![deny(rust_2018_idioms, missing_debug_implementations)]
#![allow(clippy::let_underscore_future)]

macro_rules! proto_err {
(conn: $($msg:tt)+) => {
Expand Down
2 changes: 1 addition & 1 deletion src/server/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
con.set_flags(ConnectionFlags::SLOW_REQUEST_TIMEOUT);

let state = con.clone();
ntex_rt::spawn(async move {
let _ = ntex_rt::spawn(async move {

Check warning on line 208 in src/server/service.rs

View check run for this annotation

Codecov / codecov/patch

src/server/service.rs#L208

Added line #L208 was not covered by tests
sleep(timeout).await;

if state
Expand Down
9 changes: 3 additions & 6 deletions tests/codec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#![allow(dead_code, unused_variables)]
use std::convert::TryFrom;

mod support;

use ntex_bytes::BytesMut;
Expand Down Expand Up @@ -132,19 +129,19 @@ async fn read_continuation_frames() {
.send_response(StatusCode::OK, hdrs, true)
.unwrap();

let (pseudo, hdrs, eof) = get_headers!(msg);
let (pseudo, _hdrs, eof) = get_headers!(msg);
assert_eq!(pseudo.path, Some("/index.html".into()));
assert!(eof);
};

let client_fut = async move {
let (snd, rcv) = client
let (_snd, rcv) = client
.send(Method::GET, "/index.html".into(), HeaderMap::new(), true)
.await
.expect("response");

let msg = rcv.recv().await.unwrap();
let (pseudo, hdrs, eof) = get_headers!(msg);
let (pseudo, hdrs, _eof) = get_headers!(msg);

assert_eq!(pseudo.status, Some(StatusCode::OK));
let expected = large
Expand Down
32 changes: 10 additions & 22 deletions tests/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn ssl_acceptor() -> SslAcceptor {
fn start_server() -> ntex::http::test::TestServer {
test_server(move || {
HttpService::build()
.configure_http2(|cfg| {
.h2_configure(|cfg| {
cfg.max_concurrent_streams(1);
})
.h2(|mut req: ntex::http::Request| async move {
Expand Down Expand Up @@ -72,18 +72,13 @@ async fn connect(addr: net::SocketAddr) -> IoBoxed {
async fn test_max_concurrent_streams() {
let srv = start_server();
let addr = srv.addr();
let client = client::Connector::new(fn_service(move |_| {
let addr = addr;
async move { Ok(connect(addr).await) }
}))
.scheme(Scheme::HTTP)
.connector(fn_service(move |_| {
let addr = addr;
async move { Ok(connect(addr).await) }
}))
.connect("localhost")
.await
.unwrap();
let client =
client::Connector::new(fn_service(move |_| async move { Ok(connect(addr).await) }))
.scheme(Scheme::HTTP)
.connector(fn_service(move |_| async move { Ok(connect(addr).await) }))
.connect("localhost")
.await
.unwrap();
assert!(format!("{:?}", client).contains("SimpleClient"));
assert_eq!(client.authority(), "localhost");

Expand Down Expand Up @@ -128,21 +123,15 @@ async fn test_max_concurrent_streams_pool() {
let addr = srv.addr();
let client = Client::build(
"localhost",
fn_service(move |_| {
let addr = addr;
async move { Ok(connect(addr).await) }
}),
fn_service(move |_| async move { Ok(connect(addr).await) }),
);
assert!(format!("{:?}", client).contains("ClientBuilder"));
let client = client
.maxconn(1)
.scheme(Scheme::HTTPS)
.connector(
"localhost",
fn_service(move |_| {
let addr = addr;
async move { Ok(connect(addr).await) }
}),
fn_service(move |_| async move { Ok(connect(addr).await) }),
)
.finish();
assert!(format!("{:?}", client).contains("Client"));
Expand Down Expand Up @@ -183,7 +172,6 @@ async fn test_max_concurrent_streams_pool2() {
let client = Client::build(
"localhost",
fn_service(move |_| {
let addr = addr;
cnt2.set(cnt2.get() + 1);
async move { Ok(connect(addr).await) }
}),
Expand Down
4 changes: 2 additions & 2 deletions tests/support/frames.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(dead_code, unused_variables)]
use std::{convert::TryInto, fmt};
#![allow(dead_code)]
use std::fmt;

use ntex_bytes::Bytes;
use ntex_h2::frame::{self, Frame, Protocol, PseudoHeaders, StreamId};
Expand Down
1 change: 0 additions & 1 deletion tests/support/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(dead_code, unused_variables)]
use ntex_h2::{client, server, Config, ControlMessage, Message};
use ntex_http::uri::Scheme;
use ntex_io::{testing::IoTest, Io};
Expand Down
Loading