Clippy warnings (#382)

This commit is contained in:
Nikolay Kim 2024-07-16 22:13:33 +02:00 committed by GitHub
parent 2cbc42730b
commit d39611d246
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 33 additions and 43 deletions

View file

@ -1015,7 +1015,7 @@ mod tests {
let (client, server) = IoTest::create(); let (client, server) = IoTest::create();
let f = DropFilter { p: p.clone() }; let f = DropFilter { p: p.clone() };
format!("{:?}", f); let _ = format!("{:?}", f);
let mut io = Io::new(server).add_filter(f); let mut io = Io::new(server).add_filter(f);
client.remote_buffer_cap(1024); client.remote_buffer_cap(1024);

View file

@ -496,7 +496,7 @@ mod tests {
read_order: read_order.clone(), read_order: read_order.clone(),
write_order: write_order.clone(), write_order: write_order.clone(),
}; };
format!("{:?}", counter); let _ = format!("{:?}", counter);
let io = Io::new(server).add_filter(counter); let io = Io::new(server).add_filter(counter);
client.remote_buffer_cap(1024); client.remote_buffer_cap(1024);

View file

@ -231,10 +231,7 @@ mod tests {
ntex_service::fn_service(|_| async { Ok::<_, ()>(()) }) ntex_service::fn_service(|_| async { Ok::<_, ()>(()) })
}); });
let srv = Connector::default() let srv = Connector::default().tag("T").memory_pool(PoolId::P5);
.tag("T")
.memory_pool(PoolId::P5)
.clone();
let result = srv.connect("").await; let result = srv.connect("").await;
assert!(result.is_err()); assert!(result.is_err());
let result = srv.connect("localhost:99999").await; let result = srv.connect("localhost:99999").await;

View file

@ -278,7 +278,7 @@ mod tests {
let res = srv.call("srv").await; let res = srv.call("srv").await;
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), ("srv", ())); assert_eq!(res.unwrap(), ("srv", ()));
format!("{:?}", srv); let _ = format!("{:?}", srv);
} }
#[ntex::test] #[ntex::test]
@ -301,7 +301,7 @@ mod tests {
let res = srv.call("srv").await; let res = srv.call("srv").await;
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), ("srv", ())); assert_eq!(res.unwrap(), ("srv", ()));
format!("{:?}", new_srv); let _ = format!("{:?}", new_srv);
assert!(Err == Err::from(())); assert!(Err == Err::from(()));
} }
@ -322,6 +322,6 @@ mod tests {
let res = srv.call("srv").await; let res = srv.call("srv").await;
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), ("srv", ())); assert_eq!(res.unwrap(), ("srv", ()));
format!("{:?}", new_srv); let _ = format!("{:?}", new_srv);
} }
} }

View file

@ -256,7 +256,7 @@ mod tests {
req: &'static str, req: &'static str,
ctx: ServiceCtx<'_, Self>, ctx: ServiceCtx<'_, Self>,
) -> Result<Self::Response, Self::Error> { ) -> Result<Self::Response, Self::Error> {
format!("{:?}", ctx); let _ = format!("{:?}", ctx);
#[allow(clippy::clone_on_copy)] #[allow(clippy::clone_on_copy)]
let _ = ctx.clone(); let _ = ctx.clone();
Ok(req) Ok(req)

View file

@ -380,20 +380,20 @@ mod tests {
#[ntex::test] #[ntex::test]
async fn test_fn_service() { async fn test_fn_service() {
let new_srv = fn_service(|()| async { Ok::<_, ()>("srv") }).clone(); let new_srv = fn_service(|()| async { Ok::<_, ()>("srv") }).clone();
format!("{:?}", new_srv); let _ = format!("{:?}", new_srv);
let srv = Pipeline::new(new_srv.create(()).await.unwrap()).bind(); let srv = Pipeline::new(new_srv.create(()).await.unwrap()).bind();
let res = srv.call(()).await; let res = srv.call(()).await;
assert_eq!(lazy(|cx| srv.poll_ready(cx)).await, Poll::Ready(Ok(()))); assert_eq!(lazy(|cx| srv.poll_ready(cx)).await, Poll::Ready(Ok(())));
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), "srv"); assert_eq!(res.unwrap(), "srv");
format!("{:?}", srv); let _ = format!("{:?}", srv);
let srv2 = Pipeline::new(new_srv.clone()).bind(); let srv2 = Pipeline::new(new_srv.clone()).bind();
let res = srv2.call(()).await; let res = srv2.call(()).await;
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), "srv"); assert_eq!(res.unwrap(), "srv");
format!("{:?}", srv2); let _ = format!("{:?}", srv2);
assert_eq!(lazy(|cx| srv2.poll_shutdown(cx)).await, Poll::Ready(())); assert_eq!(lazy(|cx| srv2.poll_shutdown(cx)).await, Poll::Ready(()));
} }

View file

@ -94,6 +94,6 @@ mod tests {
pipe.shutdown().await; pipe.shutdown().await;
assert!(is_called.get()); assert!(is_called.get());
format!("{:?}", pipe); let _ = format!("{:?}", pipe);
} }
} }

View file

@ -184,7 +184,7 @@ mod tests {
srv.shutdown().await; srv.shutdown().await;
assert_eq!(cnt_sht.get(), 1); assert_eq!(cnt_sht.get(), 1);
format!("{:?}", srv); let _ = format!("{:?}", srv);
} }
#[ntex::test] #[ntex::test]
@ -208,7 +208,7 @@ mod tests {
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), ("ok")); assert_eq!(res.unwrap(), ("ok"));
format!("{:?}", new_srv); let _ = format!("{:?}", new_srv);
} }
#[ntex::test] #[ntex::test]
@ -222,6 +222,6 @@ mod tests {
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), ("ok")); assert_eq!(res.unwrap(), ("ok"));
format!("{:?}", new_srv); let _ = format!("{:?}", new_srv);
} }
} }

View file

@ -134,7 +134,7 @@ mod tests {
let _ = factory.create(&10).await; let _ = factory.create(&10).await;
assert_eq!(item.get(), 11); assert_eq!(item.get(), 11);
format!("{:?}", factory); let _ = format!("{:?}", factory);
} }
#[ntex::test] #[ntex::test]

View file

@ -209,7 +209,7 @@ mod tests {
assert!(res.is_err()); assert!(res.is_err());
assert_eq!(res.err().unwrap(), "error"); assert_eq!(res.err().unwrap(), "error");
format!("{:?}", srv); let _ = format!("{:?}", srv);
} }
#[ntex::test] #[ntex::test]
@ -223,7 +223,7 @@ mod tests {
assert!(res.is_err()); assert!(res.is_err());
assert_eq!(res.err().unwrap(), "error"); assert_eq!(res.err().unwrap(), "error");
format!("{:?}", srv); let _ = format!("{:?}", srv);
} }
#[ntex::test] #[ntex::test]
@ -236,7 +236,7 @@ mod tests {
let res = srv.call(()).await; let res = srv.call(()).await;
assert!(res.is_err()); assert!(res.is_err());
assert_eq!(res.err().unwrap(), "error"); assert_eq!(res.err().unwrap(), "error");
format!("{:?}", new_srv); let _ = format!("{:?}", new_srv);
} }
#[ntex::test] #[ntex::test]
@ -250,6 +250,6 @@ mod tests {
let res = srv.call(()).await; let res = srv.call(()).await;
assert!(res.is_err()); assert!(res.is_err());
assert_eq!(res.err().unwrap(), "error"); assert_eq!(res.err().unwrap(), "error");
format!("{:?}", new_srv); let _ = format!("{:?}", new_srv);
} }
} }

View file

@ -88,7 +88,7 @@ mod tests {
assert!(factory.create(&true).await.is_err()); assert!(factory.create(&true).await.is_err());
assert!(factory.create(&false).await.is_ok()); assert!(factory.create(&false).await.is_ok());
format!("{:?}", factory); let _ = format!("{:?}", factory);
} }
#[ntex::test] #[ntex::test]
@ -108,6 +108,6 @@ mod tests {
assert!(factory.create(&true).await.is_err()); assert!(factory.create(&true).await.is_err());
assert!(factory.create(&false).await.is_ok()); assert!(factory.create(&false).await.is_ok());
format!("{:?}", factory); let _ = format!("{:?}", factory);
} }
} }

View file

@ -244,7 +244,7 @@ mod tests {
let res = srv.call(10).await; let res = srv.call(10).await;
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), 20); assert_eq!(res.unwrap(), 20);
format!("{:?} {:?}", factory, srv); let _ = format!("{:?} {:?}", factory, srv);
assert_eq!(srv.ready().await, Ok(())); assert_eq!(srv.ready().await, Ok(()));
srv.shutdown().await; srv.shutdown().await;
@ -259,7 +259,7 @@ mod tests {
let res = srv.call(10).await; let res = srv.call(10).await;
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), 20); assert_eq!(res.unwrap(), 20);
format!("{:?} {:?}", factory, srv); let _ = format!("{:?} {:?}", factory, srv);
assert_eq!(srv.ready().await, Ok(())); assert_eq!(srv.ready().await, Ok(()));
} }

View file

@ -117,7 +117,7 @@ mod tests {
let _ = tx.send(()); let _ = tx.send(());
crate::time::sleep(Duration::from_millis(25)).await; crate::time::sleep(Duration::from_millis(25)).await;
assert_eq!(lazy(|cx| srv.poll_ready(cx)).await, Poll::Ready(Ok(()))); assert_eq!(lazy(|cx| srv.poll_ready(cx)).await, Poll::Ready(Ok(())));
assert_eq!(srv.shutdown().await, ()); srv.shutdown().await;
} }
#[ntex_macros::rt_test2] #[ntex_macros::rt_test2]

View file

@ -118,7 +118,7 @@ mod tests {
let _ = tx.send(()); let _ = tx.send(());
crate::time::sleep(Duration::from_millis(25)).await; crate::time::sleep(Duration::from_millis(25)).await;
assert_eq!(lazy(|cx| srv.poll_ready(cx)).await, Poll::Ready(Ok(()))); assert_eq!(lazy(|cx| srv.poll_ready(cx)).await, Poll::Ready(Ok(())));
assert_eq!(srv.shutdown().await, ()); srv.shutdown().await;
} }
#[ntex_macros::rt_test2] #[ntex_macros::rt_test2]

View file

@ -183,7 +183,7 @@ mod tests {
Pipeline::new(TimeoutService::new(resolution, SleepService(wait_time)).clone()); Pipeline::new(TimeoutService::new(resolution, SleepService(wait_time)).clone());
assert_eq!(timeout.call(()).await, Ok(())); assert_eq!(timeout.call(()).await, Ok(()));
assert_eq!(timeout.ready().await, Ok(())); assert_eq!(timeout.ready().await, Ok(()));
assert_eq!(timeout.shutdown().await, ()); timeout.shutdown().await;
} }
#[ntex_macros::rt_test2] #[ntex_macros::rt_test2]

View file

@ -283,7 +283,7 @@ mod tests {
let service = factory.pipeline(&()).await.unwrap().clone(); let service = factory.pipeline(&()).await.unwrap().clone();
assert!(service.ready().await.is_ok()); assert!(service.ready().await.is_ok());
assert_eq!(service.shutdown().await, ()); service.shutdown().await;
assert_eq!(service.call(Variant3::V1(())).await, Ok(1)); assert_eq!(service.call(Variant3::V1(())).await, Ok(1));
assert_eq!(service.call(Variant3::V2(())).await, Ok(2)); assert_eq!(service.call(Variant3::V2(())).await, Ok(2));

View file

@ -15,6 +15,7 @@ categories = [
] ]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.75"
[package.metadata.docs.rs] [package.metadata.docs.rs]
features = ["tokio", "openssl", "rustls", "compress", "cookie", "ws", "brotli"] features = ["tokio", "openssl", "rustls", "compress", "cookie", "ws", "brotli"]

View file

@ -70,7 +70,7 @@ impl ConnectionInfo {
if scheme.is_none() { if scheme.is_none() {
if let Some(h) = req if let Some(h) = req
.headers .headers
.get(&HeaderName::from_lowercase(X_FORWARDED_PROTO).unwrap()) .get(HeaderName::from_lowercase(X_FORWARDED_PROTO).unwrap())
{ {
if let Ok(h) = h.to_str() { if let Ok(h) = h.to_str() {
scheme = h.split(',').next().map(|v| v.trim()); scheme = h.split(',').next().map(|v| v.trim());
@ -88,7 +88,7 @@ impl ConnectionInfo {
if host.is_none() { if host.is_none() {
if let Some(h) = req if let Some(h) = req
.headers .headers
.get(&HeaderName::from_lowercase(X_FORWARDED_HOST).unwrap()) .get(HeaderName::from_lowercase(X_FORWARDED_HOST).unwrap())
{ {
if let Ok(h) = h.to_str() { if let Ok(h) = h.to_str() {
host = h.split(',').next().map(|v| v.trim()); host = h.split(',').next().map(|v| v.trim());
@ -111,7 +111,7 @@ impl ConnectionInfo {
if remote.is_none() { if remote.is_none() {
if let Some(h) = req if let Some(h) = req
.headers .headers
.get(&HeaderName::from_lowercase(X_FORWARDED_FOR).unwrap()) .get(HeaderName::from_lowercase(X_FORWARDED_FOR).unwrap())
{ {
if let Ok(h) = h.to_str() { if let Ok(h) = h.to_str() {
remote = h.split(',').next().map(|v| v.trim()); remote = h.split(',').next().map(|v| v.trim());

View file

@ -339,11 +339,7 @@ impl FormatText {
} }
FormatText::ResponseHeader(ref name) => { FormatText::ResponseHeader(ref name) => {
let s = if let Some(val) = res.headers().get(name) { let s = if let Some(val) = res.headers().get(name) {
if let Ok(s) = val.to_str() { val.to_str().unwrap_or("-")
s
} else {
"-"
}
} else { } else {
"-" "-"
}; };
@ -380,11 +376,7 @@ impl FormatText {
} }
FormatText::RequestHeader(ref name) => { FormatText::RequestHeader(ref name) => {
let s = if let Some(val) = req.headers().get(name) { let s = if let Some(val) = req.headers().get(name) {
if let Ok(s) = val.to_str() { val.to_str().unwrap_or("-")
s
} else {
"-"
}
} else { } else {
"-" "-"
}; };