From 26bf2791b40694a2316a350bafe23017d3781a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20K=C5=82ak?= Date: Tue, 10 Dec 2024 15:14:54 +0100 Subject: [PATCH] Cargo clippy fixes applied --- crates/proto/src/rr/dnssec/signer.rs | 6 ++---- crates/proto/src/rr/rr_set.rs | 4 ++-- crates/proto/src/xfer/dnssec_dns_handle.rs | 4 ++-- crates/resolver/src/dns_lru.rs | 8 ++++---- crates/server/src/authority/message_request.rs | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/crates/proto/src/rr/dnssec/signer.rs b/crates/proto/src/rr/dnssec/signer.rs index a30560f6ce..f379d4e7dd 100644 --- a/crates/proto/src/rr/dnssec/signer.rs +++ b/crates/proto/src/rr/dnssec/signer.rs @@ -745,15 +745,13 @@ mod tests { #[allow(deprecated)] #[allow(clippy::unreadable_literal)] fn test_calculate_key_tag() { - let test_vectors = vec![ - (vec![33, 3, 21, 11, 3, 1, 1, 1], 9739), + let test_vectors = [(vec![33, 3, 21, 11, 3, 1, 1, 1], 9739), ( vec![ 0xc2fedb69, 0x10001, 0x6ebb9209, 0xf743, 0xc9e3, 0xd07f, 0x6275, 0x1095, ], 42354, - ), - ]; + )]; for &(ref input_data, exp_result) in test_vectors.iter() { let rsa = get_rsa_from_vec(input_data).unwrap(); diff --git a/crates/proto/src/rr/rr_set.rs b/crates/proto/src/rr/rr_set.rs index 375445cac1..167226b0d6 100644 --- a/crates/proto/src/rr/rr_set.rs +++ b/crates/proto/src/rr/rr_set.rs @@ -293,7 +293,7 @@ impl RecordSet { RecordType::SOA => { assert!(self.records.len() <= 1); - if let Some(soa_record) = self.records.get(0) { + if let Some(soa_record) = self.records.first() { match soa_record.data() { Some(RData::SOA(ref existing_soa)) => { if let Some(RData::SOA(ref new_soa)) = record.data() { @@ -866,7 +866,7 @@ mod test { #[test] #[cfg(feature = "dnssec")] // This tests RFC 6975, a DNSSEC-specific feature. - #[allow(clippy::blocks_in_if_conditions)] + #[allow(clippy::blocks_in_conditions)] fn test_get_filter() { use crate::rr::dnssec::rdata::DNSSECRData; use crate::rr::dnssec::rdata::RRSIG; diff --git a/crates/proto/src/xfer/dnssec_dns_handle.rs b/crates/proto/src/xfer/dnssec_dns_handle.rs index bcda841eed..0f7a0c1538 100644 --- a/crates/proto/src/xfer/dnssec_dns_handle.rs +++ b/crates/proto/src/xfer/dnssec_dns_handle.rs @@ -639,7 +639,7 @@ fn test_preserve() { /// Invalid RRSIGs will be ignored. RRSIGs will only be validated against DNSKEYs which can /// be validated through a chain back to the `trust_anchor`. As long as one RRSIG is valid, /// then the RRSET will be valid. -#[allow(clippy::blocks_in_if_conditions)] +#[allow(clippy::blocks_in_conditions)] async fn verify_default_rrset( handle: &DnssecDnsHandle, rrset: Rrset, @@ -860,7 +860,7 @@ fn verify_rrset_with_dnskey(_: &DNSKEY, _: &RRSIG, _: &Rrset) -> ProtoResult<()> /// corresponding RRSIG RR, a validator MUST ignore the settings of the /// NSEC and RRSIG bits in an NSEC RR. /// ``` -#[allow(clippy::blocks_in_if_conditions)] +#[allow(clippy::blocks_in_conditions)] #[doc(hidden)] pub fn verify_nsec(query: &Query, soa_name: &Name, nsecs: &[&Record]) -> bool { // TODO: consider converting this to Result, and giving explicit reason for the failure diff --git a/crates/resolver/src/dns_lru.rs b/crates/resolver/src/dns_lru.rs index 9321749555..687c685985 100644 --- a/crates/resolver/src/dns_lru.rs +++ b/crates/resolver/src/dns_lru.rs @@ -410,7 +410,7 @@ mod tests { Record::from_rdata(name.clone(), 1, RData::A(A::new(127, 0, 0, 1))), 1, )]; - let ips = vec![RData::A(A::new(127, 0, 0, 1))]; + let ips = [RData::A(A::new(127, 0, 0, 1))]; // configure the cache with a minimum TTL of 2 seconds. let ttls = TtlConfig { @@ -500,7 +500,7 @@ mod tests { Record::from_rdata(name.clone(), 62, RData::A(A::new(127, 0, 0, 1))), 62, )]; - let ips = vec![RData::A(A::new(127, 0, 0, 1))]; + let ips = [RData::A(A::new(127, 0, 0, 1))]; // configure the cache with a maximum TTL of 60 seconds. let ttls = TtlConfig { @@ -589,7 +589,7 @@ mod tests { Record::from_rdata(name, 1, RData::A(A::new(127, 0, 0, 1))), 1, )]; - let ips = vec![RData::A(A::new(127, 0, 0, 1))]; + let ips = [RData::A(A::new(127, 0, 0, 1))]; let lru = DnsLru::new(1, TtlConfig::default()); let rc_ips = lru.insert(query.clone(), ips_ttl, now); @@ -609,7 +609,7 @@ mod tests { Record::from_rdata(name, 10, RData::A(A::new(127, 0, 0, 1))), 10, )]; - let ips = vec![RData::A(A::new(127, 0, 0, 1))]; + let ips = [RData::A(A::new(127, 0, 0, 1))]; let lru = DnsLru::new(1, TtlConfig::default()); let rc_ips = lru.insert(query.clone(), ips_ttl, now); diff --git a/crates/server/src/authority/message_request.rs b/crates/server/src/authority/message_request.rs index b2abb65e41..6af05328eb 100644 --- a/crates/server/src/authority/message_request.rs +++ b/crates/server/src/authority/message_request.rs @@ -277,7 +277,7 @@ impl Queries { length: self.queries.len(), // We don't generally support more than one query, but this will at least give us one // cache entry. - first_query: self.queries.get(0), + first_query: self.queries.first(), cached_serialized: self.original.as_ref(), } }