diff --git a/examples/src/grpc-web/client.rs b/examples/src/grpc-web/client.rs index f4b9728ab..af3f348cb 100644 --- a/examples/src/grpc-web/client.rs +++ b/examples/src/grpc-web/client.rs @@ -84,6 +84,7 @@ where body.advance(1); let len = body.get_u32(); + #[allow(clippy::let_and_return)] let msg = T::decode(&mut body.split_to(len as usize)).unwrap(); msg diff --git a/tests/compression/src/lib.rs b/tests/compression/src/lib.rs index bb6f5dcc8..de806b5cb 100644 --- a/tests/compression/src/lib.rs +++ b/tests/compression/src/lib.rs @@ -28,19 +28,11 @@ mod util; tonic::include_proto!("test"); -#[derive(Debug)] +#[derive(Debug, Default)] struct Svc { disable_compressing_on_response: bool, } -impl Default for Svc { - fn default() -> Self { - Self { - disable_compressing_on_response: false, - } - } -} - const UNCOMPRESSED_MIN_BODY_SIZE: usize = 1024; impl Svc { diff --git a/tonic-build/src/client.rs b/tonic-build/src/client.rs index b315c5d51..5f04d44b4 100644 --- a/tonic-build/src/client.rs +++ b/tonic-build/src/client.rs @@ -15,7 +15,7 @@ pub fn generate( attributes: &Attributes, ) -> TokenStream { let service_ident = quote::format_ident!("{}Client", service.name()); - let client_mod = quote::format_ident!("{}_client", naive_snake_case(&service.name())); + let client_mod = quote::format_ident!("{}_client", naive_snake_case(service.name())); let methods = generate_methods(service, emit_package, proto_path, compile_well_known_types); let connect = generate_connect(&service_ident); diff --git a/tonic-build/src/server.rs b/tonic-build/src/server.rs index 683734cd8..2a047ecf5 100644 --- a/tonic-build/src/server.rs +++ b/tonic-build/src/server.rs @@ -19,7 +19,7 @@ pub fn generate( let server_service = quote::format_ident!("{}Server", service.name()); let server_trait = quote::format_ident!("{}", service.name()); - let server_mod = quote::format_ident!("{}_server", naive_snake_case(&service.name())); + let server_mod = quote::format_ident!("{}_server", naive_snake_case(service.name())); let generated_trait = generate_trait( service, proto_path, diff --git a/tonic-health/src/lib.rs b/tonic-health/src/lib.rs index 689583453..ed9078a20 100644 --- a/tonic-health/src/lib.rs +++ b/tonic-health/src/lib.rs @@ -29,7 +29,7 @@ pub mod proto { #![allow(missing_docs)] tonic::include_proto!("grpc.health.v1"); - pub const GRPC_HEALTH_V1_FILE_DESCRIPTOR_SET: &'static [u8] = + pub const GRPC_HEALTH_V1_FILE_DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("grpc_health_v1"); } diff --git a/tonic-reflection/build.rs b/tonic-reflection/build.rs index de2f08e1f..0ad2cef81 100644 --- a/tonic-reflection/build.rs +++ b/tonic-reflection/build.rs @@ -7,6 +7,10 @@ fn main() -> Result<(), Box> { tonic_build::configure() .file_descriptor_set_path(&reflection_descriptor) + .type_attribute( + "ServerReflectionResponse.message_response", + "#[allow(clippy::enum_variant_names)]", + ) .build_server(true) .build_client(true) // Client is only used for tests .format(true) diff --git a/tonic-reflection/src/server.rs b/tonic-reflection/src/server.rs index d306ab326..571c0744e 100644 --- a/tonic-reflection/src/server.rs +++ b/tonic-reflection/src/server.rs @@ -147,15 +147,15 @@ impl<'b> Builder<'b> { let prefix = &fd.package.clone().unwrap_or_default(); for msg in &fd.message_type { - self.process_message(fd.clone(), &prefix, msg)?; + self.process_message(fd.clone(), prefix, msg)?; } for en in &fd.enum_type { - self.process_enum(fd.clone(), &prefix, en)?; + self.process_enum(fd.clone(), prefix, en)?; } for service in &fd.service { - let service_name = extract_name(&prefix, "service", service.name.as_ref())?; + let service_name = extract_name(prefix, "service", service.name.as_ref())?; self.service_names.push(service_name.clone()); self.symbols.insert(service_name.clone(), fd.clone()); diff --git a/tonic/src/metadata/map.rs b/tonic/src/metadata/map.rs index 017479d26..4870db239 100644 --- a/tonic/src/metadata/map.rs +++ b/tonic/src/metadata/map.rs @@ -1223,7 +1223,7 @@ impl<'a> Iterator for Iter<'a> { fn next(&mut self) -> Option { self.inner.next().map(|item| { - let (ref name, value) = item; + let (name, value) = item; if Ascii::is_valid_key(name.as_str()) { KeyAndValueRef::Ascii( MetadataKey::unchecked_from_header_name_ref(name), @@ -1315,7 +1315,7 @@ impl<'a> Iterator for Values<'a> { fn next(&mut self) -> Option { self.inner.next().map(|item| { - let (ref name, value) = item; + let (name, value) = item; if Ascii::is_valid_key(name.as_str()) { ValueRef::Ascii(MetadataValue::unchecked_from_header_value_ref(value)) } else { diff --git a/tonic/src/status.rs b/tonic/src/status.rs index ee560c9f3..e2aa656a3 100644 --- a/tonic/src/status.rs +++ b/tonic/src/status.rs @@ -498,7 +498,7 @@ impl Status { if !self.message.is_empty() { let to_write = Bytes::copy_from_slice( - Cow::from(percent_encode(&self.message().as_bytes(), ENCODING_SET)).as_bytes(), + Cow::from(percent_encode(self.message().as_bytes(), ENCODING_SET)).as_bytes(), ); header_map.insert( @@ -697,7 +697,7 @@ pub(crate) fn infer_grpc_status( status_code: http::StatusCode, ) -> Result<(), Option> { if let Some(trailers) = trailers { - if let Some(status) = Status::from_header_map(&trailers) { + if let Some(status) = Status::from_header_map(trailers) { if status.code() == Code::Ok { return Ok(()); } else { diff --git a/tonic/src/transport/tls.rs b/tonic/src/transport/tls.rs index 97b5a6c59..a4151c748 100644 --- a/tonic/src/transport/tls.rs +++ b/tonic/src/transport/tls.rs @@ -24,7 +24,7 @@ impl Certificate { /// Get a immutable reference to underlying certificate pub fn get_ref(&self) -> &[u8] { - &self.pem.as_slice() + self.pem.as_slice() } /// Get a mutable reference to underlying certificate