Skip to content

Commit 211678f

Browse files
committed
chore(grpc): Apply workspace lint config to grpc crate
1 parent 969408e commit 211678f

File tree

8 files changed

+16
-14
lines changed

8 files changed

+16
-14
lines changed

grpc/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ prost = "0.14"
3838
default = ["dns"]
3939
dns = ["dep:hickory-resolver"]
4040

41+
[lints]
42+
workspace = true
43+
4144
[package.metadata.cargo_check_external_types]
4245
allowed_external_types = [
4346
"tonic::*",

grpc/src/client/load_balancing/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl ParsedJsonLbConfig {
8989
pub fn new(json: &str) -> Result<Self, String> {
9090
match serde_json::from_str(json) {
9191
Ok(value) => Ok(ParsedJsonLbConfig { value }),
92-
Err(e) => Err(format!("failed to parse LB config JSON: {}", e)),
92+
Err(e) => Err(format!("failed to parse LB config JSON: {e}")),
9393
}
9494
}
9595

@@ -108,7 +108,7 @@ impl ParsedJsonLbConfig {
108108
let res: T = match serde_json::from_value(self.value.clone()) {
109109
Ok(v) => v,
110110
Err(e) => {
111-
return Err(format!("{}", e).into());
111+
return Err(format!("{e}").into());
112112
}
113113
};
114114
Ok(res)

grpc/src/client/name_resolution/dns/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ impl ResolverBuilder for Builder {
204204
let host = match endpoint.host {
205205
Host::Domain(d) => d,
206206
Host::Ipv4(ipv4) => {
207-
return nop_resolver_for_ip(IpAddr::V4(ipv4), endpoint.port, options)
207+
return nop_resolver_for_ip(IpAddr::V4(ipv4), endpoint.port, options);
208208
}
209209
Host::Ipv6(ipv6) => {
210-
return nop_resolver_for_ip(IpAddr::V6(ipv6), endpoint.port, options)
210+
return nop_resolver_for_ip(IpAddr::V6(ipv6), endpoint.port, options);
211211
}
212212
};
213213
let authority = parsed.authority;
@@ -233,7 +233,7 @@ impl ResolverBuilder for Builder {
233233

234234
fn is_valid_uri(&self, target: &Target) -> bool {
235235
if let Err(err) = parse_endpoint_and_authority(target) {
236-
eprintln!("{}", err);
236+
eprintln!("{err}");
237237
false
238238
} else {
239239
true
@@ -311,7 +311,7 @@ fn parse_endpoint_and_authority(target: &Target) -> Result<ParseResult, String>
311311
let endpoint = target.path();
312312
let endpoint = endpoint.strip_prefix("/").unwrap_or(endpoint);
313313
let parse_result = parse_host_port(endpoint, DEFAULT_PORT)
314-
.map_err(|err| format!("Failed to parse target {}: {}", target, err))?;
314+
.map_err(|err| format!("Failed to parse target {target}: {err}"))?;
315315
let endpoint = parse_result.ok_or("Received empty endpoint host.".to_string())?;
316316

317317
// Parse the authority.
@@ -323,7 +323,7 @@ fn parse_endpoint_and_authority(target: &Target) -> Result<ParseResult, String>
323323
});
324324
}
325325
let parse_result = parse_host_port(&authority, DEFAULT_DNS_PORT)
326-
.map_err(|err| format!("Failed to parse DNS authority {}: {}", target, err))?;
326+
.map_err(|err| format!("Failed to parse DNS authority {target}: {err}"))?;
327327
let Some(authority) = parse_result else {
328328
return Ok(ParseResult {
329329
endpoint,
@@ -351,7 +351,7 @@ fn parse_host_port(host_and_port: &str, default_port: u16) -> Result<Option<Host
351351
// We need to use the https scheme otherwise url::Url::parse doesn't convert
352352
// IP addresses to Host::Ipv4 or Host::Ipv6 if they could represent valid
353353
// domains.
354-
let url = format!("https://{}", host_and_port);
354+
let url = format!("https://{host_and_port}");
355355
let url = url.parse::<url::Url>().map_err(|err| err.to_string())?;
356356
let port = url.port().unwrap_or(default_port);
357357
let host = match url.host() {

grpc/src/client/name_resolution/dns/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ pub async fn rate_limit() {
414414
resolver.resolve_now();
415415
tokio::select! {
416416
_ = work_rx.recv() => {
417-
panic!("Received unexpected work request from resolver: {:?}", event);
417+
panic!("Received unexpected work request from resolver: {event:?}");
418418
}
419419
_ = tokio::time::sleep(DEFAULT_TEST_SHORT_TIMEOUT) => {
420420
println!("No work requested from resolver.");

grpc/src/client/name_resolution/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl Target {
107107
let host = self.authority_host();
108108
let port = self.authority_port();
109109
if let Some(port) = port {
110-
format!("{}:{}", host, port)
110+
format!("{host}:{port}")
111111
} else {
112112
host.to_owned()
113113
}

grpc/src/client/name_resolution/registry.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ impl ResolverRegistry {
6666
let scheme = builder.scheme();
6767
if scheme.chars().any(|c| c.is_ascii_uppercase()) {
6868
return Err(format!(
69-
"Scheme must not contain uppercase characters: {}",
70-
scheme
69+
"Scheme must not contain uppercase characters: {scheme}",
7170
));
7271
}
7372
self.inner

grpc/src/rt/tokio/hickory_resolver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ mod tests {
228228
let addr = socket.local_addr().unwrap();
229229
server.register_socket(socket);
230230

231-
println!("DNS server running on {}", addr);
231+
println!("DNS server running on {addr}");
232232

233233
let (tx, rx) = oneshot::channel::<()>();
234234
let server_task = tokio::spawn(async move {

grpc/src/rt/tokio/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl DnsResolver for TokioDefaultDnsResolver {
4848
async fn lookup_host_name(&self, name: &str) -> Result<Vec<IpAddr>, String> {
4949
let name_with_port = match name.parse::<IpAddr>() {
5050
Ok(ip) => SocketAddr::new(ip, 0).to_string(),
51-
Err(_) => format!("{}:0", name),
51+
Err(_) => format!("{name}:0"),
5252
};
5353
let ips = tokio::net::lookup_host(name_with_port)
5454
.await

0 commit comments

Comments
 (0)