diff --git a/codegen/src/main.rs b/codegen/src/main.rs index 4b88039a1..7659ad93d 100644 --- a/codegen/src/main.rs +++ b/codegen/src/main.rs @@ -1,4 +1,4 @@ -use std::path::PathBuf; +use std::path::{Path, PathBuf}; fn main() { // tonic-health @@ -45,11 +45,11 @@ fn main() { } fn codegen( - root_dir: &PathBuf, + root_dir: &Path, iface_files: &[&str], include_dirs: &[&str], - out_dir: &PathBuf, - file_descriptor_set_path: &PathBuf, + out_dir: &Path, + file_descriptor_set_path: &Path, build_client: bool, build_server: bool, ) { @@ -59,12 +59,12 @@ fn codegen( .unwrap(); let iface_files: Vec = iface_files - .into_iter() + .iter() .map(|&path| root_dir.join(path)) .collect(); let include_dirs: Vec = include_dirs - .into_iter() + .iter() .map(|&path| root_dir.join(path)) .collect(); let out_dir = root_dir.join(out_dir); diff --git a/examples/src/dynamic/server.rs b/examples/src/dynamic/server.rs index e25c7e8ae..300ec868c 100644 --- a/examples/src/dynamic/server.rs +++ b/examples/src/dynamic/server.rs @@ -32,10 +32,7 @@ impl Echo for MyEcho { } fn init_echo(args: &[String], builder: &mut RoutesBuilder) { - let enabled = args - .into_iter() - .find(|arg| arg.as_str() == "echo") - .is_some(); + let enabled = args.iter().any(|arg| arg.as_str() == "echo"); if enabled { println!("Adding Echo service..."); let svc = EchoServer::new(MyEcho::default()); @@ -62,10 +59,7 @@ impl Greeter for MyGreeter { } fn init_greeter(args: &[String], builder: &mut RoutesBuilder) { - let enabled = args - .into_iter() - .find(|arg| arg.as_str() == "greeter") - .is_some(); + let enabled = args.iter().any(|arg| arg.as_str() == "greeter"); if enabled { println!("Adding Greeter service..."); diff --git a/tonic-build/src/server.rs b/tonic-build/src/server.rs index 9e42789ef..d9ab1ad6b 100644 --- a/tonic-build/src/server.rs +++ b/tonic-build/src/server.rs @@ -9,6 +9,7 @@ use proc_macro2::{Span, TokenStream}; use quote::quote; use syn::{Ident, Lit, LitStr}; +#[allow(clippy::too_many_arguments)] pub(crate) fn generate_internal( service: &T, emit_package: bool, @@ -209,6 +210,7 @@ pub(crate) fn generate_internal( } } +#[allow(clippy::too_many_arguments)] fn generate_trait( service: &T, emit_package: bool, diff --git a/tonic-web/src/call.rs b/tonic-web/src/call.rs index 353e644e5..68c9674bb 100644 --- a/tonic-web/src/call.rs +++ b/tonic-web/src/call.rs @@ -423,7 +423,7 @@ fn make_trailers_frame(trailers: HeaderMap) -> Vec { /// or the buffer jsut contained grpc message frames. fn find_trailers(buf: &[u8]) -> FindTrailers { let mut len = 0; - let mut temp_buf = &buf[..]; + let mut temp_buf = buf; loop { // To check each frame, there must be at least GRPC_HEADER_SIZE @@ -448,7 +448,7 @@ fn find_trailers(buf: &[u8]) -> FindTrailers { return FindTrailers::IncompleteBuf; } - temp_buf = &buf[len as usize..]; + temp_buf = &buf[len..]; } } @@ -503,7 +503,7 @@ mod tests { fn find_trailers_non_buffered() { // Byte version of this: // b"\x80\0\0\0\x0fgrpc-status:0\r\n" - let buf = vec![ + let buf = [ 128, 0, 0, 0, 15, 103, 114, 112, 99, 45, 115, 116, 97, 116, 117, 115, 58, 48, 13, 10, ]; @@ -516,7 +516,7 @@ mod tests { fn find_trailers_buffered() { // Byte version of this: // b"\0\0\0\0L\n$975738af-1a17-4aea-b887-ed0bbced6093\x1a$da609e9b-f470-4cc0-a691-3fd6a005a436\x80\0\0\0\x0fgrpc-status:0\r\n" - let buf = vec![ + let buf = [ 0, 0, 0, 0, 76, 10, 36, 57, 55, 53, 55, 51, 56, 97, 102, 45, 49, 97, 49, 55, 45, 52, 97, 101, 97, 45, 98, 56, 56, 55, 45, 101, 100, 48, 98, 98, 99, 101, 100, 54, 48, 57, 51, 26, 36, 100, 97, 54, 48, 57, 101, 57, 98, 45, 102, 52, 55, 48, 45, 52, 99, 99, 48, diff --git a/tonic-web/tests/integration/tests/grpc.rs b/tonic-web/tests/integration/tests/grpc.rs index 8e81ef68c..98eca1f92 100644 --- a/tonic-web/tests/integration/tests/grpc.rs +++ b/tonic-web/tests/integration/tests/grpc.rs @@ -129,7 +129,7 @@ async fn spawn() -> Result<(Client, Client, Client, Client), Error> { let ((s1, u1), (s2, u2), (s3, u3), (s4, u4)) = join!(grpc(true), grpc(false), grpc_web(true), grpc_web(false)); - let _ = tokio::spawn(async move { join!(s1, s2, s3, s4) }); + drop(tokio::spawn(async move { join!(s1, s2, s3, s4) })); tokio::time::sleep(Duration::from_millis(30)).await; diff --git a/tonic-web/tests/integration/tests/grpc_web.rs b/tonic-web/tests/integration/tests/grpc_web.rs index e062a8380..3343d754c 100644 --- a/tonic-web/tests/integration/tests/grpc_web.rs +++ b/tonic-web/tests/integration/tests/grpc_web.rs @@ -65,7 +65,7 @@ async fn spawn() -> String { let url = format!("http://{}", listener.local_addr().unwrap()); let listener_stream = TcpListenerStream::new(listener); - let _ = tokio::spawn(async move { + drop(tokio::spawn(async move { Server::builder() .accept_http1(true) .layer(GrpcWebLayer::new()) @@ -73,7 +73,7 @@ async fn spawn() -> String { .serve_with_incoming(listener_stream) .await .unwrap() - }); + })); url } diff --git a/tonic/src/codec/encode.rs b/tonic/src/codec/encode.rs index bd48ee47b..593634f93 100644 --- a/tonic/src/codec/encode.rs +++ b/tonic/src/codec/encode.rs @@ -106,14 +106,14 @@ where BytesMut::new() }; - return EncodedBytes { + Self { source: Fuse::new(source), encoder, compression_encoding, max_message_size, buf, uncompression_buf, - }; + } } } diff --git a/tonic/src/codec/prost.rs b/tonic/src/codec/prost.rs index 47e736a71..d2f1652f4 100644 --- a/tonic/src/codec/prost.rs +++ b/tonic/src/codec/prost.rs @@ -326,7 +326,6 @@ mod tests { } } - #[allow(clippy::drop_ref)] fn poll_trailers( self: Pin<&mut Self>, _cx: &mut Context<'_>,