From 2dd09c02bd356fa709f3cc1bf9fca865091eebc7 Mon Sep 17 00:00:00 2001 From: tottoto Date: Wed, 14 Dec 2022 01:29:29 +0900 Subject: [PATCH] chore: Fix clippy lint (#1181) --- examples/src/blocking/server.rs | 2 +- interop/src/lib.rs | 6 +-- tests/disable_comments/Cargo.toml | 2 +- tests/disable_comments/build.rs | 2 +- tests/extern_path/uuid/Cargo.toml | 2 +- tests/integration_tests/tests/streams.rs | 2 +- tests/root-crate-path/src/main.rs | 1 + tests/wellknown-compiled/Cargo.toml | 2 +- tonic-build/Cargo.toml | 2 +- tonic-health/src/generated/grpc.health.v1.rs | 2 + tonic-health/src/lib.rs | 2 +- tonic-reflection/Cargo.toml | 2 +- .../src/generated/grpc.reflection.v1alpha.rs | 10 ++++ tonic-types/src/generated/google.rpc.rs | 15 ++++++ .../src/richer_error/error_details/mod.rs | 6 +++ tonic-types/src/richer_error/mod.rs | 28 +++++----- .../richer_error/std_messages/bad_request.rs | 2 +- .../richer_error/std_messages/retry_info.rs | 4 +- tonic-web/src/layer.rs | 6 +++ tonic/src/metadata/key.rs | 2 +- tonic/src/metadata/map.rs | 54 +++++++++---------- tonic/src/service/interceptor.rs | 2 +- tonic/src/transport/service/io.rs | 4 +- 23 files changed, 98 insertions(+), 62 deletions(-) diff --git a/examples/src/blocking/server.rs b/examples/src/blocking/server.rs index 043c427..d7ef617 100644 --- a/examples/src/blocking/server.rs +++ b/examples/src/blocking/server.rs @@ -21,7 +21,7 @@ impl Greeter for MyGreeter { println!("Got a request: {:?}", request); let reply = hello_world::HelloReply { - message: format!("Hello {}!", request.into_inner().name).into(), + message: format!("Hello {}!", request.into_inner().name), }; Ok(Response::new(reply)) diff --git a/interop/src/lib.rs b/interop/src/lib.rs index 5891ecd..7c279c8 100644 --- a/interop/src/lib.rs +++ b/interop/src/lib.rs @@ -113,7 +113,7 @@ impl fmt::Display for TestAssertion { macro_rules! test_assert { ($description:expr, $assertion:expr) => { if $assertion { - crate::TestAssertion::Passed { + $crate::TestAssertion::Passed { description: $description, } } else { @@ -126,11 +126,11 @@ macro_rules! test_assert { }; ($description:expr, $assertion:expr, $why:expr) => { if $assertion { - crate::TestAssertion::Passed { + $crate::TestAssertion::Passed { description: $description, } } else { - crate::TestAssertion::Failed { + $crate::TestAssertion::Failed { description: $description, expression: stringify!($assertion), why: Some($why), diff --git a/tests/disable_comments/Cargo.toml b/tests/disable_comments/Cargo.toml index fe0c372..3cc7dff 100644 --- a/tests/disable_comments/Cargo.toml +++ b/tests/disable_comments/Cargo.toml @@ -13,5 +13,5 @@ prost = "0.11" tonic = { path = "../../tonic" } [build-dependencies] -prost-build = "0.11" +prost-build = "0.11.4" tonic-build = { path = "../../tonic-build" } diff --git a/tests/disable_comments/build.rs b/tests/disable_comments/build.rs index 9b0f8bf..3bb311b 100644 --- a/tests/disable_comments/build.rs +++ b/tests/disable_comments/build.rs @@ -1,6 +1,6 @@ fn main() { let mut config = prost_build::Config::default(); - config.disable_comments(&["test.Input1", "test.Output1"]); + config.disable_comments(["test.Input1", "test.Output1"]); tonic_build::configure() .disable_comments("test.Service1") .disable_comments("test.Service1.Rpc1") diff --git a/tests/extern_path/uuid/Cargo.toml b/tests/extern_path/uuid/Cargo.toml index 3c44808..28d420f 100644 --- a/tests/extern_path/uuid/Cargo.toml +++ b/tests/extern_path/uuid/Cargo.toml @@ -12,4 +12,4 @@ version = "0.1.0" bytes = "1.0" prost = "0.11" [build-dependencies] -prost-build = "0.11" +prost-build = "0.11.4" diff --git a/tests/integration_tests/tests/streams.rs b/tests/integration_tests/tests/streams.rs index 152aca5..de0c6b4 100644 --- a/tests/integration_tests/tests/streams.rs +++ b/tests/integration_tests/tests/streams.rs @@ -17,7 +17,7 @@ async fn status_from_server_stream_with_source() { &self, _: Request, ) -> Result, Status> { - let s = Unsync(0 as *mut ()); + let s = Unsync(std::ptr::null_mut::<()>()); Ok(Response::new(Box::pin(s) as Self::StreamCallStream)) } diff --git a/tests/root-crate-path/src/main.rs b/tests/root-crate-path/src/main.rs index bf879bc..c6bf45a 100644 --- a/tests/root-crate-path/src/main.rs +++ b/tests/root-crate-path/src/main.rs @@ -1,3 +1,4 @@ +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Animal { #[prost(string, optional, tag = "1")] diff --git a/tests/wellknown-compiled/Cargo.toml b/tests/wellknown-compiled/Cargo.toml index 7741cb2..fc66698 100644 --- a/tests/wellknown-compiled/Cargo.toml +++ b/tests/wellknown-compiled/Cargo.toml @@ -16,5 +16,5 @@ prost = "0.11" tonic = {path = "../../tonic"} [build-dependencies] -prost-build = "0.11" +prost-build = "0.11.4" tonic-build = {path = "../../tonic-build"} diff --git a/tonic-build/Cargo.toml b/tonic-build/Cargo.toml index 5a10bc7..7616706 100644 --- a/tonic-build/Cargo.toml +++ b/tonic-build/Cargo.toml @@ -17,7 +17,7 @@ version = "0.8.4" [dependencies] prettyplease = { version = "0.1" } proc-macro2 = "1.0" -prost-build = { version = "0.11.2", optional = true } +prost-build = { version = "0.11.4", optional = true } quote = "1.0" syn = "1.0" diff --git a/tonic-health/src/generated/grpc.health.v1.rs b/tonic-health/src/generated/grpc.health.v1.rs index 30dd885..e9f9cfc 100644 --- a/tonic-health/src/generated/grpc.health.v1.rs +++ b/tonic-health/src/generated/grpc.health.v1.rs @@ -1,8 +1,10 @@ +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct HealthCheckRequest { #[prost(string, tag = "1")] pub service: ::prost::alloc::string::String, } +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct HealthCheckResponse { #[prost(enumeration = "health_check_response::ServingStatus", tag = "1")] diff --git a/tonic-health/src/lib.rs b/tonic-health/src/lib.rs index 920f9bf..a892306 100644 --- a/tonic-health/src/lib.rs +++ b/tonic-health/src/lib.rs @@ -36,7 +36,7 @@ pub mod proto { pub mod server; /// An enumeration of values representing gRPC service health. -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum ServingStatus { /// Unknown status Unknown, diff --git a/tonic-reflection/Cargo.toml b/tonic-reflection/Cargo.toml index e94e481..beedf1a 100644 --- a/tonic-reflection/Cargo.toml +++ b/tonic-reflection/Cargo.toml @@ -27,6 +27,6 @@ tonic = { version = "0.8", path = "../tonic", default-features = false, features [dev-dependencies] tonic = { version = "0.8", path = "../tonic", default-features = false, features = ["transport"] } -tonic-build = { version = "0.8", path = "../tonic-build", default-features = false, features = ["prost"] } +tonic-build = { version = "0.8", path = "../tonic-build", default-features = false, features = ["prost", "cleanup-markdown"] } futures = "0.3" futures-util = "0.3" diff --git a/tonic-reflection/src/generated/grpc.reflection.v1alpha.rs b/tonic-reflection/src/generated/grpc.reflection.v1alpha.rs index ef3e013..0e2f4e2 100644 --- a/tonic-reflection/src/generated/grpc.reflection.v1alpha.rs +++ b/tonic-reflection/src/generated/grpc.reflection.v1alpha.rs @@ -1,4 +1,5 @@ /// The message sent by the client when calling ServerReflectionInfo method. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ServerReflectionRequest { #[prost(string, tag = "1")] @@ -16,6 +17,7 @@ pub mod server_reflection_request { /// To use reflection service, the client should set one of the following /// fields in message_request. The server distinguishes requests by their /// defined field and then handles them using corresponding methods. + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum MessageRequest { /// Find a proto file by the file name. @@ -48,6 +50,7 @@ pub mod server_reflection_request { } /// The type name and extension number sent by the client when requesting /// file_containing_extension. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ExtensionRequest { /// Fully-qualified type name. The format should be . @@ -57,6 +60,7 @@ pub struct ExtensionRequest { pub extension_number: i32, } /// The message sent by the server to answer ServerReflectionInfo method. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ServerReflectionResponse { #[prost(string, tag = "1")] @@ -74,6 +78,7 @@ pub struct ServerReflectionResponse { pub mod server_reflection_response { /// The server sets one of the following fields according to the /// message_request in the request. + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum MessageResponse { /// This message is used to answer file_by_filename, file_containing_symbol, @@ -98,6 +103,7 @@ pub mod server_reflection_response { /// Serialized FileDescriptorProto messages sent by the server answering /// a file_by_filename, file_containing_symbol, or file_containing_extension /// request. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FileDescriptorResponse { /// Serialized FileDescriptorProto messages. We avoid taking a dependency on @@ -108,6 +114,7 @@ pub struct FileDescriptorResponse { } /// A list of extension numbers sent by the server answering /// all_extension_numbers_of_type request. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ExtensionNumberResponse { /// Full name of the base type, including the package name. The format @@ -118,6 +125,7 @@ pub struct ExtensionNumberResponse { pub extension_number: ::prost::alloc::vec::Vec, } /// A list of ServiceResponse sent by the server answering list_services request. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ListServiceResponse { /// The information of each service may be expanded in the future, so we use @@ -127,6 +135,7 @@ pub struct ListServiceResponse { } /// The information of a single service used by ListServiceResponse to answer /// list_services request. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ServiceResponse { /// Full name of a registered service, including its package name. The format @@ -135,6 +144,7 @@ pub struct ServiceResponse { pub name: ::prost::alloc::string::String, } /// The error code and error message sent by the server when an error occurs. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ErrorResponse { /// This field uses the error codes defined in grpc::StatusCode. diff --git a/tonic-types/src/generated/google.rpc.rs b/tonic-types/src/generated/google.rpc.rs index 1937ae2..a8d991d 100644 --- a/tonic-types/src/generated/google.rpc.rs +++ b/tonic-types/src/generated/google.rpc.rs @@ -5,6 +5,7 @@ /// /// You can find out more about this error model and how to work with it in the /// [API Design Guide](). +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Status { /// The status code, which should be an enum value of \\[google.rpc.Code\]\[google.rpc.Code\\]. @@ -33,6 +34,7 @@ pub struct Status { /// the delay between retries based on `retry_delay`, until either a maximum /// number of retries have been reached or a maximum retry delay cap has been /// reached. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RetryInfo { /// Clients should wait at least this long between retrying the same request. @@ -40,6 +42,7 @@ pub struct RetryInfo { pub retry_delay: ::core::option::Option<::prost_types::Duration>, } /// Describes additional debugging info. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct DebugInfo { /// The stack trace entries indicating where the error occurred. @@ -60,6 +63,7 @@ pub struct DebugInfo { /// /// Also see RetryInfo and Help types for other details about handling a /// quota failure. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct QuotaFailure { /// Describes all quota violations. @@ -70,6 +74,7 @@ pub struct QuotaFailure { pub mod quota_failure { /// A message type used to describe a single quota violation. For example, a /// daily quota or a custom quota that was exceeded. + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Violation { /// The subject on which the quota check failed. @@ -116,6 +121,7 @@ pub mod quota_failure { /// } /// } /// ``` +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ErrorInfo { /// The reason of the error. This is a constant value that identifies the @@ -151,6 +157,7 @@ pub struct ErrorInfo { /// For example, if an RPC failed because it required the Terms of Service to be /// acknowledged, it could list the terms of service violation in the /// PreconditionFailure message. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct PreconditionFailure { /// Describes all precondition violations. @@ -160,6 +167,7 @@ pub struct PreconditionFailure { /// Nested message and enum types in `PreconditionFailure`. pub mod precondition_failure { /// A message type used to describe a single precondition failure. + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Violation { /// The type of PreconditionFailure. We recommend using a service-specific @@ -182,6 +190,7 @@ pub mod precondition_failure { } /// Describes violations in a client request. This error type focuses on the /// syntactic aspects of the request. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct BadRequest { /// Describes all violations in a client request. @@ -191,6 +200,7 @@ pub struct BadRequest { /// Nested message and enum types in `BadRequest`. pub mod bad_request { /// A message type used to describe a single bad request field. + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct FieldViolation { /// A path leading to a field in the request body. The value will be a @@ -205,6 +215,7 @@ pub mod bad_request { } /// Contains metadata about the request that clients can attach when filing a bug /// or providing other forms of feedback. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RequestInfo { /// An opaque string that should only be interpreted by the service generating @@ -217,6 +228,7 @@ pub struct RequestInfo { pub serving_data: ::prost::alloc::string::String, } /// Describes the resource that is being accessed. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ResourceInfo { /// A name for the type of resource being accessed, e.g. "sql table", @@ -245,6 +257,7 @@ pub struct ResourceInfo { /// For example, if a quota check failed with an error indicating the calling /// project hasn't enabled the accessed service, this can contain a URL pointing /// directly to the right place in the developer console to flip the bit. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Help { /// URL(s) pointing to additional information on handling the current error. @@ -254,6 +267,7 @@ pub struct Help { /// Nested message and enum types in `Help`. pub mod help { /// Describes a URL link. + #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Link { /// Describes what the link offers. @@ -266,6 +280,7 @@ pub mod help { } /// Provides a localized error message that is safe to return to the user /// which can be attached to an RPC error. +#[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct LocalizedMessage { /// The locale used following the specification defined at diff --git a/tonic-types/src/richer_error/error_details/mod.rs b/tonic-types/src/richer_error/error_details/mod.rs index ab43903..c49d746 100644 --- a/tonic-types/src/richer_error/error_details/mod.rs +++ b/tonic-types/src/richer_error/error_details/mod.rs @@ -247,3 +247,9 @@ impl ErrorDetails { false } } + +impl Default for ErrorDetails { + fn default() -> Self { + Self::new() + } +} diff --git a/tonic-types/src/richer_error/mod.rs b/tonic-types/src/richer_error/mod.rs index 853bc15..48422f8 100644 --- a/tonic-types/src/richer_error/mod.rs +++ b/tonic-types/src/richer_error/mod.rs @@ -20,10 +20,10 @@ trait FromAny { Self: Sized; } -fn gen_details_bytes(code: Code, message: &String, details: Vec) -> Bytes { +fn gen_details_bytes(code: Code, message: &str, details: Vec) -> Bytes { let status = pb::Status { code: code as i32, - message: message.clone(), + message: message.to_owned(), details, }; @@ -411,7 +411,7 @@ impl StatusExt for tonic::Status { } fn get_error_details(&self) -> ErrorDetails { - self.check_error_details().unwrap_or(ErrorDetails::new()) + self.check_error_details().unwrap_or_default() } fn check_error_details_vec(&self) -> Result, DecodeError> { @@ -438,19 +438,17 @@ impl StatusExt for tonic::Status { } fn get_error_details_vec(&self) -> Vec { - self.check_error_details_vec().unwrap_or(Vec::new()) + self.check_error_details_vec().unwrap_or_default() } fn get_details_retry_info(&self) -> Option { let status = pb::Status::decode(self.details()).ok()?; for any in status.details.into_iter() { - match any.type_url.as_str() { - RetryInfo::TYPE_URL => match RetryInfo::from_any(any) { - Ok(detail) => return Some(detail), - Err(_) => {} - }, - _ => {} + if any.type_url.as_str() == RetryInfo::TYPE_URL { + if let Ok(detail) = RetryInfo::from_any(any) { + return Some(detail); + } } } @@ -477,12 +475,10 @@ impl StatusExt for tonic::Status { let status = pb::Status::decode(self.details()).ok()?; for any in status.details.into_iter() { - match any.type_url.as_str() { - BadRequest::TYPE_URL => match BadRequest::from_any(any) { - Ok(detail) => return Some(detail), - Err(_) => {} - }, - _ => {} + if any.type_url.as_str() == BadRequest::TYPE_URL { + if let Ok(detail) = BadRequest::from_any(any) { + return Some(detail); + } } } diff --git a/tonic-types/src/richer_error/std_messages/bad_request.rs b/tonic-types/src/richer_error/std_messages/bad_request.rs index 26b0f05..08afeeb 100644 --- a/tonic-types/src/richer_error/std_messages/bad_request.rs +++ b/tonic-types/src/richer_error/std_messages/bad_request.rs @@ -153,7 +153,7 @@ mod tests { ); assert!( - br_details.is_empty() == false, + !br_details.is_empty(), "filled BadRequest returns 'true' from .is_empty()" ); diff --git a/tonic-types/src/richer_error/std_messages/retry_info.rs b/tonic-types/src/richer_error/std_messages/retry_info.rs index 36a132a..ca0b363 100644 --- a/tonic-types/src/richer_error/std_messages/retry_info.rs +++ b/tonic-types/src/richer_error/std_messages/retry_info.rs @@ -7,7 +7,7 @@ use super::super::{pb, FromAny, IntoAny}; /// Used to encode/decode the `RetryInfo` standard error message described in /// [error_details.proto]. Describes when the clients can retry a failed -/// request. +/// request. /// Note: When obtained from decoding `RetryInfo` messages, negative /// `retry_delay`'s become 0. /// @@ -119,7 +119,7 @@ mod tests { ); assert!( - error_info.is_empty() == false, + !error_info.is_empty(), "filled RetryInfo returns 'false' from .has_retry_delay()" ); diff --git a/tonic-web/src/layer.rs b/tonic-web/src/layer.rs index 5efa746..8386785 100644 --- a/tonic-web/src/layer.rs +++ b/tonic-web/src/layer.rs @@ -16,6 +16,12 @@ impl GrpcWebLayer { } } +impl Default for GrpcWebLayer { + fn default() -> Self { + Self::new() + } +} + impl Layer for GrpcWebLayer where S: Service, Response = http::Response>, diff --git a/tonic/src/metadata/key.rs b/tonic/src/metadata/key.rs index 9efd9f0..a5a1248 100644 --- a/tonic/src/metadata/key.rs +++ b/tonic/src/metadata/key.rs @@ -247,7 +247,7 @@ impl PartialEq> for str { /// ``` #[inline] fn eq(&self, other: &MetadataKey) -> bool { - (*other).inner == *self + other.inner == *self } } diff --git a/tonic/src/metadata/map.rs b/tonic/src/metadata/map.rs index 4870db2..3c7820c 100644 --- a/tonic/src/metadata/map.rs +++ b/tonic/src/metadata/map.rs @@ -1362,7 +1362,7 @@ where match self.inner { Some(ref mut inner) => inner .next() - .map(&MetadataValue::unchecked_from_header_value_ref), + .map(MetadataValue::unchecked_from_header_value_ref), None => None, } } @@ -1383,7 +1383,7 @@ where match self.inner { Some(ref mut inner) => inner .next_back() - .map(&MetadataValue::unchecked_from_header_value_ref), + .map(MetadataValue::unchecked_from_header_value_ref), None => None, } } @@ -1400,7 +1400,7 @@ where fn next(&mut self) -> Option { self.inner .next() - .map(&MetadataValue::unchecked_from_mut_header_value_ref) + .map(MetadataValue::unchecked_from_mut_header_value_ref) } } @@ -1411,7 +1411,7 @@ where fn next_back(&mut self) -> Option { self.inner .next_back() - .map(&MetadataValue::unchecked_from_mut_header_value_ref) + .map(MetadataValue::unchecked_from_mut_header_value_ref) } } @@ -1992,7 +1992,7 @@ impl<'a, 'b: 'a, VE: ValueEncoding> IntoIterator for &'b GetAll<'a, VE> { fn into_iter(self) -> ValueIter<'a, VE> { ValueIter { - inner: (&self.inner).as_ref().map(|inner| inner.into_iter()), + inner: self.inner.as_ref().map(|inner| inner.into_iter()), phantom: PhantomData, } } @@ -2037,7 +2037,7 @@ mod into_metadata_key { ) -> Option> { map.headers .insert(self.inner, val.inner) - .map(&MetadataValue::unchecked_from_header_value) + .map(MetadataValue::unchecked_from_header_value) } #[doc(hidden)] @@ -2059,7 +2059,7 @@ mod into_metadata_key { ) -> Option> { map.headers .insert(&self.inner, val.inner) - .map(&MetadataValue::unchecked_from_header_value) + .map(MetadataValue::unchecked_from_header_value) } #[doc(hidden)] #[inline] @@ -2083,7 +2083,7 @@ mod into_metadata_key { map.headers .insert(key.inner, val.inner) - .map(&MetadataValue::unchecked_from_header_value) + .map(MetadataValue::unchecked_from_header_value) } #[doc(hidden)] #[inline] @@ -2141,7 +2141,7 @@ mod as_metadata_key { fn get(self, map: &MetadataMap) -> Option<&MetadataValue> { map.headers .get(self.inner) - .map(&MetadataValue::unchecked_from_header_value_ref) + .map(MetadataValue::unchecked_from_header_value_ref) } #[doc(hidden)] @@ -2149,7 +2149,7 @@ mod as_metadata_key { fn get_mut(self, map: &mut MetadataMap) -> Option<&mut MetadataValue> { map.headers .get_mut(self.inner) - .map(&MetadataValue::unchecked_from_mut_header_value_ref) + .map(MetadataValue::unchecked_from_mut_header_value_ref) } #[doc(hidden)] @@ -2172,7 +2172,7 @@ mod as_metadata_key { fn remove(self, map: &mut MetadataMap) -> Option> { map.headers .remove(self.inner) - .map(&MetadataValue::unchecked_from_header_value) + .map(MetadataValue::unchecked_from_header_value) } } @@ -2184,7 +2184,7 @@ mod as_metadata_key { fn get(self, map: &MetadataMap) -> Option<&MetadataValue> { map.headers .get(&self.inner) - .map(&MetadataValue::unchecked_from_header_value_ref) + .map(MetadataValue::unchecked_from_header_value_ref) } #[doc(hidden)] @@ -2192,7 +2192,7 @@ mod as_metadata_key { fn get_mut(self, map: &mut MetadataMap) -> Option<&mut MetadataValue> { map.headers .get_mut(&self.inner) - .map(&MetadataValue::unchecked_from_mut_header_value_ref) + .map(MetadataValue::unchecked_from_mut_header_value_ref) } #[doc(hidden)] @@ -2215,7 +2215,7 @@ mod as_metadata_key { fn remove(self, map: &mut MetadataMap) -> Option> { map.headers .remove(&self.inner) - .map(&MetadataValue::unchecked_from_header_value) + .map(MetadataValue::unchecked_from_header_value) } } @@ -2230,7 +2230,7 @@ mod as_metadata_key { } map.headers .get(self) - .map(&MetadataValue::unchecked_from_header_value_ref) + .map(MetadataValue::unchecked_from_header_value_ref) } #[doc(hidden)] @@ -2241,7 +2241,7 @@ mod as_metadata_key { } map.headers .get_mut(self) - .map(&MetadataValue::unchecked_from_mut_header_value_ref) + .map(MetadataValue::unchecked_from_mut_header_value_ref) } #[doc(hidden)] @@ -2277,7 +2277,7 @@ mod as_metadata_key { } map.headers .remove(self) - .map(&MetadataValue::unchecked_from_header_value) + .map(MetadataValue::unchecked_from_header_value) } } @@ -2292,7 +2292,7 @@ mod as_metadata_key { } map.headers .get(self.as_str()) - .map(&MetadataValue::unchecked_from_header_value_ref) + .map(MetadataValue::unchecked_from_header_value_ref) } #[doc(hidden)] @@ -2303,7 +2303,7 @@ mod as_metadata_key { } map.headers .get_mut(self.as_str()) - .map(&MetadataValue::unchecked_from_mut_header_value_ref) + .map(MetadataValue::unchecked_from_mut_header_value_ref) } #[doc(hidden)] @@ -2338,7 +2338,7 @@ mod as_metadata_key { } map.headers .remove(self.as_str()) - .map(&MetadataValue::unchecked_from_header_value) + .map(MetadataValue::unchecked_from_header_value) } } @@ -2353,7 +2353,7 @@ mod as_metadata_key { } map.headers .get(self.as_str()) - .map(&MetadataValue::unchecked_from_header_value_ref) + .map(MetadataValue::unchecked_from_header_value_ref) } #[doc(hidden)] @@ -2364,7 +2364,7 @@ mod as_metadata_key { } map.headers .get_mut(self.as_str()) - .map(&MetadataValue::unchecked_from_mut_header_value_ref) + .map(MetadataValue::unchecked_from_mut_header_value_ref) } #[doc(hidden)] @@ -2399,7 +2399,7 @@ mod as_metadata_key { } map.headers .remove(self.as_str()) - .map(&MetadataValue::unchecked_from_header_value) + .map(MetadataValue::unchecked_from_header_value) } } @@ -2520,7 +2520,7 @@ mod tests { let mut found_x_word = false; for key_and_value in map.iter() { - if let KeyAndValueRef::Ascii(ref key, ref _value) = key_and_value { + if let KeyAndValueRef::Ascii(key, _value) = key_and_value { if key.as_str() == "x-word" { found_x_word = true; } else { @@ -2540,7 +2540,7 @@ mod tests { let mut found_x_word_bin = false; for key_and_value in map.iter() { - if let KeyAndValueRef::Binary(ref key, ref _value) = key_and_value { + if let KeyAndValueRef::Binary(key, _value) = key_and_value { if key.as_str() == "x-word-bin" { found_x_word_bin = true; } else { @@ -2561,7 +2561,7 @@ mod tests { let mut found_x_word = false; for key_and_value in map.iter_mut() { - if let KeyAndMutValueRef::Ascii(ref key, ref _value) = key_and_value { + if let KeyAndMutValueRef::Ascii(key, _value) = key_and_value { if key.as_str() == "x-word" { found_x_word = true; } else { @@ -2581,7 +2581,7 @@ mod tests { let mut found_x_word_bin = false; for key_and_value in map.iter_mut() { - if let KeyAndMutValueRef::Binary(ref key, ref _value) = key_and_value { + if let KeyAndMutValueRef::Binary(key, _value) = key_and_value { if key.as_str() == "x-word-bin" { found_x_word_bin = true; } else { diff --git a/tonic/src/service/interceptor.rs b/tonic/src/service/interceptor.rs index cb8d46b..398f8ef 100644 --- a/tonic/src/service/interceptor.rs +++ b/tonic/src/service/interceptor.rs @@ -349,7 +349,7 @@ mod tests { Ok::<_, hyper::Error>(hyper::Response::new(hyper::Body::empty())) }); - let svc = InterceptedService::new(svc, |request: crate::Request<()>| Ok(request)); + let svc = InterceptedService::new(svc, Ok); let request = http::Request::builder() .method(http::Method::OPTIONS) diff --git a/tonic/src/transport/service/io.rs b/tonic/src/transport/service/io.rs index 0419336..2b46535 100644 --- a/tonic/src/transport/service/io.rs +++ b/tonic/src/transport/service/io.rs @@ -70,7 +70,7 @@ impl AsyncWrite for BoxedIo { pub(crate) enum ServerIo { Io(IO), #[cfg(feature = "tls")] - TlsIo(TlsStream), + TlsIo(Box>), } use tower::util::Either; @@ -89,7 +89,7 @@ impl ServerIo { #[cfg(feature = "tls")] pub(in crate::transport) fn new_tls_io(io: TlsStream) -> Self { - Self::TlsIo(io) + Self::TlsIo(Box::new(io)) } #[cfg(feature = "tls")]