Skip to content

Commit a55d3cc

Browse files
Merge pull request #1111 from sozu-proxy/devel/fdubois/chore/apply-clippy
chore: apply cargo clippy
2 parents 57b4fc9 + b05fced commit a55d3cc

File tree

18 files changed

+82
-48
lines changed

18 files changed

+82
-48
lines changed

command/src/config.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,10 +1364,12 @@ impl ConfigBuilder {
13641364
})
13651365
{
13661366
//println!("using listener certificate for {:}", frontend.address);
1367-
frontend.certificate = https_listener.certificate.clone();
1367+
frontend
1368+
.certificate
1369+
.clone_from(&https_listener.certificate);
13681370
frontend.certificate_chain =
13691371
Some(https_listener.certificate_chain.clone());
1370-
frontend.key = https_listener.key.clone();
1372+
frontend.key.clone_from(&https_listener.key);
13711373
}
13721374
if frontend.certificate.is_none() {
13731375
debug!("known addresses: {:#?}", self.known_addresses);

command/src/logging/logs.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,12 @@ macro_rules! _prompt_log {
764764
pub struct LogLineCachedState(u8);
765765
const LOG_LINE_ENABLED: u8 = 1 << 7;
766766

767+
impl Default for LogLineCachedState {
768+
fn default() -> Self {
769+
Self::new()
770+
}
771+
}
772+
767773
impl LogLineCachedState {
768774
pub const fn new() -> Self {
769775
Self(0)

command/src/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,13 +2195,13 @@ mod tests {
21952195
certificates_found_by_fingerprint
21962196
);
21972197

2198-
assert!(certificates_found_by_fingerprint.len() >= 1);
2198+
assert!(!certificates_found_by_fingerprint.is_empty());
21992199

22002200
let certificate_found_by_domain_name = state.get_certificates(QueryCertificatesFilters {
22012201
domain: Some("lolcatho.st".to_string()),
22022202
fingerprint: None,
22032203
});
22042204

2205-
assert!(certificate_found_by_domain_name.len() >= 1);
2205+
assert!(!certificate_found_by_domain_name.is_empty());
22062206
}
22072207
}

e2e/src/sozu/command_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl CommandID {
1717

1818
pub fn next(&mut self) -> String {
1919
let id = format!("{}{}", self.prefix, self.id);
20-
self.last = id.to_owned();
20+
id.clone_into(&mut self.last);
2121
self.id += 1;
2222
id
2323
}

e2e/src/tests/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn setup_test<S: Into<String>>(
9292
RequestType::AddBackend(Worker::default_backend(
9393
"cluster_0",
9494
format!("cluster_0-{i}"),
95-
back_address.into(),
95+
back_address,
9696
if should_stick {
9797
Some(format!("sticky_cluster_0-{i}"))
9898
} else {

e2e/src/tests/tests.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,13 @@ pub fn try_tls_endpoint() -> State {
362362
let mut worker = Worker::start_new_worker("TLS-ENDPOINT", config, &listeners, state);
363363

364364
worker.send_proxy_request_type(RequestType::AddHttpsListener(
365-
ListenerBuilder::new_https(front_address.clone().into())
365+
ListenerBuilder::new_https(front_address.clone())
366366
.to_tls(None)
367367
.unwrap(),
368368
));
369369

370370
worker.send_proxy_request_type(RequestType::ActivateListener(ActivateListener {
371-
address: front_address.clone().into(),
371+
address: front_address.clone(),
372372
proxy: ListenerType::Https.into(),
373373
from_scm: false,
374374
}));
@@ -391,7 +391,7 @@ pub fn try_tls_endpoint() -> State {
391391
names: vec![],
392392
};
393393
let add_certificate = AddCertificate {
394-
address: front_address.into(),
394+
address: front_address,
395395
certificate: certificate_and_key,
396396
expired_at: None,
397397
};
@@ -1062,7 +1062,7 @@ pub fn try_blue_geen() -> State {
10621062
worker.send_proxy_request_type(RequestType::AddBackend(Worker::default_backend(
10631063
"cluster_0",
10641064
"cluster_0-0",
1065-
primary_address.into(),
1065+
primary_address,
10661066
None,
10671067
)));
10681068
worker.read_to_last();
@@ -1081,7 +1081,7 @@ pub fn try_blue_geen() -> State {
10811081
worker.send_proxy_request_type(RequestType::AddBackend(Worker::default_backend(
10821082
"cluster_0",
10831083
"cluster_0-1",
1084-
secondary_address.into(),
1084+
secondary_address,
10851085
None,
10861086
)));
10871087
worker.read_to_last();
@@ -1138,7 +1138,7 @@ pub fn try_keep_alive() -> State {
11381138

11391139
let mut backend = backends.pop().unwrap();
11401140
let mut client = Client::new(
1141-
format!("client"),
1141+
"client".to_string(),
11421142
front_address,
11431143
"GET /api HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n",
11441144
);
@@ -1220,7 +1220,7 @@ pub fn try_stick() -> State {
12201220
let mut backend2 = backends.pop().unwrap();
12211221
let mut backend1 = backends.pop().unwrap();
12221222
let mut client = Client::new(
1223-
format!("client"),
1223+
"client".to_string(),
12241224
front_address,
12251225
"GET /api HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\nCookie: foo=bar\r\n\r\n",
12261226
);
@@ -1423,7 +1423,7 @@ pub fn try_head() -> State {
14231423
let mut client = Client::new(
14241424
"client",
14251425
front_address,
1426-
http_request("HEAD", "/api", format!("ping"), "localhost"),
1426+
http_request("HEAD", "/api", "ping".to_string(), "localhost"),
14271427
);
14281428

14291429
client.connect();
@@ -1559,13 +1559,13 @@ fn try_wildcard() -> State {
15591559
let mut backend0 = SyncBackend::new(
15601560
"BACKEND_0",
15611561
back_address,
1562-
http_ok_response(format!("pong0")),
1562+
http_ok_response("pong0".to_string()),
15631563
);
15641564

15651565
let mut client = Client::new(
15661566
"client",
15671567
front_address,
1568-
http_request("POST", "/api", format!("ping"), "www.sozu.io"),
1568+
http_request("POST", "/api", "ping".to_string(), "www.sozu.io"),
15691569
);
15701570

15711571
backend0.connect();
@@ -1604,7 +1604,7 @@ fn try_wildcard() -> State {
16041604
let mut backend1 = SyncBackend::new(
16051605
"BACKEND_1",
16061606
back_address,
1607-
http_ok_response(format!("pong1")),
1607+
http_ok_response("pong1".to_string()),
16081608
);
16091609

16101610
worker.read_to_last();

lib/src/backends.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,9 @@ impl BackendList {
405405
// keeping connection retry state
406406
Some(old_backend) => {
407407
let mut b = old_backend.borrow_mut();
408-
b.sticky_id = backend.sticky_id.clone();
409-
b.load_balancing_parameters = backend.load_balancing_parameters.clone();
408+
b.sticky_id.clone_from(&backend.sticky_id);
409+
b.load_balancing_parameters
410+
.clone_from(&backend.load_balancing_parameters);
410411
b.backup = backend.backup;
411412
}
412413
}

lib/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,13 @@ impl Display for Readiness {
860860
display_ready(r, self.event);
861861
display_ready(mixed, self.interest & self.event);
862862

863-
write!(f, "I({:?})&R({:?})=M({:?})", String::from_utf8_lossy(i), String::from_utf8_lossy(r), String::from_utf8_lossy(mixed))
863+
write!(
864+
f,
865+
"I({:?})&R({:?})=M({:?})",
866+
String::from_utf8_lossy(i),
867+
String::from_utf8_lossy(r),
868+
String::from_utf8_lossy(mixed)
869+
)
864870
}
865871
}
866872

lib/src/load_balancing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,6 @@ mod test {
246246
backends.remove(1);
247247

248248
let backend2 = roundrobin.next_available_backend(&mut backends);
249-
assert_eq!(backend2.as_ref(), backends.get(0));
249+
assert_eq!(backend2.as_ref(), backends.first());
250250
}
251251
}

lib/src/metrics/local_drain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ mod tests {
610610
local_drain
611611
.metrics_of_one_backend(
612612
"test-backend-1",
613-
&["connections_per_backend".to_string()].to_vec(),
613+
["connections_per_backend".to_string()].as_ref(),
614614
)
615615
.expect("could not query metrics for this backend")
616616
)
@@ -645,7 +645,7 @@ mod tests {
645645
};
646646

647647
let returned_cluster_metrics = local_drain
648-
.metrics_of_one_cluster("test-cluster", &["http_errors".to_string()].to_vec())
648+
.metrics_of_one_cluster("test-cluster", ["http_errors".to_string()].as_ref())
649649
.expect("could not query metrics for this cluster");
650650

651651
assert_eq!(expected_cluster_metrics, returned_cluster_metrics);

0 commit comments

Comments
 (0)