Skip to content

Commit

Permalink
chore: Fix clippy lints (#881)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Jan 12, 2022
1 parent 4548997 commit 366d888
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 20 deletions.
1 change: 1 addition & 0 deletions examples/src/grpc-web/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 1 addition & 9 deletions tests/compression/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tonic-build/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn generate<T: Service>(
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);
Expand Down
2 changes: 1 addition & 1 deletion tonic-build/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn generate<T: Service>(

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,
Expand Down
2 changes: 1 addition & 1 deletion tonic-health/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
4 changes: 4 additions & 0 deletions tonic-reflection/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

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)
Expand Down
6 changes: 3 additions & 3 deletions tonic-reflection/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
4 changes: 2 additions & 2 deletions tonic/src/metadata/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ impl<'a> Iterator for Iter<'a> {

fn next(&mut self) -> Option<Self::Item> {
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),
Expand Down Expand Up @@ -1315,7 +1315,7 @@ impl<'a> Iterator for Values<'a> {

fn next(&mut self) -> Option<Self::Item> {
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 {
Expand Down
4 changes: 2 additions & 2 deletions tonic/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -697,7 +697,7 @@ pub(crate) fn infer_grpc_status(
status_code: http::StatusCode,
) -> Result<(), Option<Status>> {
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 {
Expand Down
2 changes: 1 addition & 1 deletion tonic/src/transport/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 366d888

Please sign in to comment.