Skip to content

Commit 0b1798d

Browse files
authored
*: make clippy happy (#658)
...and - remove deprecated method - fix doc warnings - regenerate code Signed-off-by: Jay Lee <[email protected]>
1 parent 2463081 commit 0b1798d

File tree

37 files changed

+88
-152
lines changed

37 files changed

+88
-152
lines changed

benchmark/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn main() {
4545
.build()
4646
.unwrap();
4747
let port = server
48-
.add_listening_port(&format!("[::]:{port}"), ServerCredentials::insecure())
48+
.add_listening_port(format!("[::]:{port}"), ServerCredentials::insecure())
4949
.unwrap();
5050

5151
info!("listening on [::]:{}", port);

benchmark/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl Server {
8686
ServerCredentials::insecure()
8787
};
8888
let port = s
89-
.add_listening_port(&format!("[::]:{}", cfg.port), creds)
89+
.add_listening_port(format!("[::]:{}", cfg.port), creds)
9090
.unwrap();
9191
s.start();
9292
Ok(Server {

benchmark/src/worker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use grpc_proto::testing::control::{
88
ClientArgs, ClientStatus, CoreRequest, CoreResponse, ServerArgs, ServerStatus, Void,
99
};
1010
use grpc_proto::testing::services_grpc::WorkerService;
11-
use grpcio::{DuplexSink, Error, RequestStream, RpcContext, UnarySink, WriteFlags};
11+
use grpcio::{DuplexSink, RequestStream, RpcContext, UnarySink, WriteFlags};
1212

1313
use crate::client::Client;
1414
use crate::server::Server;
@@ -36,7 +36,7 @@ impl WorkerService for Worker {
3636
) {
3737
let f = async move {
3838
let arg = match stream.try_next().await? {
39-
None => return sink.close().await.map_err(Error::from),
39+
None => return sink.close().await,
4040
Some(arg) => arg,
4141
};
4242
#[cfg(feature = "protobuf-codec")]

compiler/src/codegen.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,18 @@ impl<'a> CodeWriter<'a> {
136136
}
137137

138138
pub fn field_entry(&mut self, name: &str, value: &str) {
139-
self.write_line(&format!("{name}: {value},"));
139+
self.write_line(format!("{name}: {value},"));
140140
}
141141

142142
pub fn field_decl(&mut self, name: &str, field_type: &str) {
143-
self.write_line(&format!("{name}: {field_type},"));
143+
self.write_line(format!("{name}: {field_type},"));
144144
}
145145

146146
pub fn comment(&mut self, comment: &str) {
147147
if comment.is_empty() {
148148
self.write_line("//");
149149
} else {
150-
self.write_line(&format!("// {comment}"));
150+
self.write_line(format!("// {comment}"));
151151
}
152152
}
153153

@@ -397,15 +397,15 @@ impl<'a> MethodGen<'a> {
397397
// Unary
398398
MethodType::Unary => {
399399
w.pub_fn(&self.unary_opt(&method_name), |w| {
400-
w.write_line(&format!(
400+
w.write_line(format!(
401401
"self.client.unary_call(&{}, req, opt)",
402402
self.const_method_name()
403403
));
404404
});
405405
w.write_line("");
406406

407407
w.pub_fn(&self.unary(&method_name), |w| {
408-
w.write_line(&format!(
408+
w.write_line(format!(
409409
"self.{}_opt(req, {})",
410410
method_name,
411411
fq_grpc("CallOption::default()")
@@ -414,15 +414,15 @@ impl<'a> MethodGen<'a> {
414414
w.write_line("");
415415

416416
w.pub_fn(&self.unary_async_opt(&method_name), |w| {
417-
w.write_line(&format!(
417+
w.write_line(format!(
418418
"self.client.unary_call_async(&{}, req, opt)",
419419
self.const_method_name()
420420
));
421421
});
422422
w.write_line("");
423423

424424
w.pub_fn(&self.unary_async(&method_name), |w| {
425-
w.write_line(&format!(
425+
w.write_line(format!(
426426
"self.{}_async_opt(req, {})",
427427
method_name,
428428
fq_grpc("CallOption::default()")
@@ -433,15 +433,15 @@ impl<'a> MethodGen<'a> {
433433
// Client streaming
434434
MethodType::ClientStreaming => {
435435
w.pub_fn(&self.client_streaming_opt(&method_name), |w| {
436-
w.write_line(&format!(
436+
w.write_line(format!(
437437
"self.client.client_streaming(&{}, opt)",
438438
self.const_method_name()
439439
));
440440
});
441441
w.write_line("");
442442

443443
w.pub_fn(&self.client_streaming(&method_name), |w| {
444-
w.write_line(&format!(
444+
w.write_line(format!(
445445
"self.{}_opt({})",
446446
method_name,
447447
fq_grpc("CallOption::default()")
@@ -452,15 +452,15 @@ impl<'a> MethodGen<'a> {
452452
// Server streaming
453453
MethodType::ServerStreaming => {
454454
w.pub_fn(&self.server_streaming_opt(&method_name), |w| {
455-
w.write_line(&format!(
455+
w.write_line(format!(
456456
"self.client.server_streaming(&{}, req, opt)",
457457
self.const_method_name()
458458
));
459459
});
460460
w.write_line("");
461461

462462
w.pub_fn(&self.server_streaming(&method_name), |w| {
463-
w.write_line(&format!(
463+
w.write_line(format!(
464464
"self.{}_opt(req, {})",
465465
method_name,
466466
fq_grpc("CallOption::default()")
@@ -471,15 +471,15 @@ impl<'a> MethodGen<'a> {
471471
// Duplex streaming
472472
MethodType::Duplex => {
473473
w.pub_fn(&self.duplex_streaming_opt(&method_name), |w| {
474-
w.write_line(&format!(
474+
w.write_line(format!(
475475
"self.client.duplex_streaming(&{}, opt)",
476476
self.const_method_name()
477477
));
478478
});
479479
w.write_line("");
480480

481481
w.pub_fn(&self.duplex_streaming(&method_name), |w| {
482-
w.write_line(&format!(
482+
w.write_line(format!(
483483
"self.{}_opt({})",
484484
method_name,
485485
fq_grpc("CallOption::default()")
@@ -526,7 +526,7 @@ impl<'a> MethodGen<'a> {
526526
),
527527
"});",
528528
|w| {
529-
w.write_line(&format!("instance.{}(ctx, req, resp)", self.name()));
529+
w.write_line(format!("instance.{}(ctx, req, resp)", self.name()));
530530
},
531531
);
532532
}

compiler/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct NameSpliter<'a> {
99
pos: usize,
1010
}
1111

12-
impl<'a> NameSpliter<'a> {
12+
impl NameSpliter<'_> {
1313
fn new(s: &str) -> NameSpliter {
1414
NameSpliter {
1515
name: s.as_bytes(),

grpc-sys/build.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ fn clean_up_stale_cache(cxx_compiler: String) {
7777
};
7878
let cache_stale = f.lines().any(|l| {
7979
let l = l.unwrap();
80-
trim_start(&l, "CMAKE_CXX_COMPILER:").map_or(false, |s| {
80+
trim_start(&l, "CMAKE_CXX_COMPILER:").is_some_and(|s| {
8181
let mut splits = s.splitn(2, '=');
8282
splits.next();
83-
splits.next().map_or(false, |p| p != cxx_compiler)
83+
splits.next().is_some_and(|p| p != cxx_compiler)
8484
})
8585
});
8686
// CMake can't handle compiler change well, it will invalidate cache without respecting command
@@ -158,14 +158,14 @@ fn build_grpc(cc: &mut cc::Build, library: &str) {
158158
let dst = {
159159
let mut config = CmakeConfig::new("grpc");
160160

161-
if get_env("CARGO_CFG_TARGET_OS").map_or(false, |s| s == "macos") {
161+
if get_env("CARGO_CFG_TARGET_OS").is_some_and(|s| s == "macos") {
162162
config.cxxflag("-stdlib=libc++");
163163
println!("cargo:rustc-link-lib=resolv");
164164
}
165165

166166
// Ensure CoreFoundation be found in macos or ios
167-
if get_env("CARGO_CFG_TARGET_OS").map_or(false, |s| s == "macos")
168-
|| get_env("CARGO_CFG_TARGET_OS").map_or(false, |s| s == "ios")
167+
if get_env("CARGO_CFG_TARGET_OS").is_some_and(|s| s == "macos")
168+
|| get_env("CARGO_CFG_TARGET_OS").is_some_and(|s| s == "ios")
169169
{
170170
println!("cargo:rustc-link-lib=framework=CoreFoundation");
171171
}
@@ -252,7 +252,7 @@ fn build_grpc(cc: &mut cc::Build, library: &str) {
252252
if !cfg!(feature = "_list-package") {
253253
config.build_target(library);
254254
}
255-
config.uses_cxx11().build()
255+
config.build()
256256
};
257257

258258
let lib_suffix = if target.contains("msvc") {
@@ -541,12 +541,12 @@ fn main() {
541541
"grpc_unsecure"
542542
};
543543

544-
if get_env("CARGO_CFG_TARGET_OS").map_or(false, |s| s == "windows") {
544+
if get_env("CARGO_CFG_TARGET_OS").is_some_and(|s| s == "windows") {
545545
// At lease vista
546546
cc.define("_WIN32_WINNT", Some("0x600"));
547547
}
548548

549-
if get_env("GRPCIO_SYS_USE_PKG_CONFIG").map_or(false, |s| s == "1") {
549+
if get_env("GRPCIO_SYS_USE_PKG_CONFIG").is_some_and(|s| s == "1") {
550550
// Print cargo metadata.
551551
let lib_core = probe_library(library, true);
552552
for inc_path in lib_core.include_paths {

grpc-sys/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(non_snake_case)]
55
#![allow(non_upper_case_globals)]
66
#[allow(clippy::all)]
7+
#[allow(rustdoc::all)]
78
mod bindings {
89
include!(env!("BINDING_PATH"));
910
}

health/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
//! ```
3333
3434
#[allow(renamed_and_removed_lints)]
35+
#[allow(static_mut_refs)]
3536
pub mod proto;
3637
mod service;
3738

health/src/proto/prost/grpc.health.v1.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// This file is @generated by prost-build.
2-
#[allow(clippy::derive_partial_eq_without_eq)]
32
#[derive(Clone, PartialEq, ::prost::Message)]
43
pub struct HealthCheckRequest {
54
#[prost(string, tag = "1")]
65
pub service: ::prost::alloc::string::String,
76
}
8-
#[allow(clippy::derive_partial_eq_without_eq)]
97
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
108
pub struct HealthCheckResponse {
119
#[prost(enumeration = "health_check_response::ServingStatus", tag = "1")]
@@ -39,10 +37,10 @@ pub mod health_check_response {
3937
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
4038
pub fn as_str_name(&self) -> &'static str {
4139
match self {
42-
ServingStatus::Unknown => "UNKNOWN",
43-
ServingStatus::Serving => "SERVING",
44-
ServingStatus::NotServing => "NOT_SERVING",
45-
ServingStatus::ServiceUnknown => "SERVICE_UNKNOWN",
40+
Self::Unknown => "UNKNOWN",
41+
Self::Serving => "SERVING",
42+
Self::NotServing => "NOT_SERVING",
43+
Self::ServiceUnknown => "SERVICE_UNKNOWN",
4644
}
4745
}
4846
/// Creates an enum from field names used in the ProtoBuf definition.

health/src/proto/protobuf_v3/health.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file is generated by rust-protobuf 3.5.0. Do not edit
1+
// This file is generated by rust-protobuf 3.7.2. Do not edit
22
// @generated
33

44
// https://github.com/rust-lang/rust-clippy/issues/702
@@ -8,7 +8,6 @@
88
#![allow(unused_attributes)]
99
#![cfg_attr(rustfmt, rustfmt::skip)]
1010

11-
#![allow(box_pointers)]
1211
#![allow(dead_code)]
1312
#![allow(missing_docs)]
1413
#![allow(non_camel_case_types)]
@@ -22,7 +21,7 @@
2221
2322
/// Generated files are compatible only with the same version
2423
/// of protobuf runtime.
25-
const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_5_0;
24+
const _PROTOBUF_VERSION_CHECK: () = ::protobufv3::VERSION_3_7_2;
2625

2726
// @@protoc_insertion_point(message:grpc.health.v1.HealthCheckRequest)
2827
#[derive(PartialEq,Clone,Default,Debug)]

0 commit comments

Comments
 (0)