From 007016e1ff8bf330ce3f7aab3d97ff566e622f5d Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 22 Apr 2026 14:09:59 +0200 Subject: [PATCH 1/3] tests: prefer turbofishing over type annotations --- tests/x509_limbo.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/x509_limbo.rs b/tests/x509_limbo.rs index eda5280c..6de4d2e9 100644 --- a/tests/x509_limbo.rs +++ b/tests/x509_limbo.rs @@ -18,7 +18,7 @@ use webpki::{ #[ignore] // Runs slower than other unit tests - opt-in with `cargo test -- --include-ignored` #[test] fn x509_limbo() { - let limbo: Limbo = serde_json::from_slice(LIMBO_JSON).expect("invalid test JSON"); + let limbo = serde_json::from_slice::(LIMBO_JSON).expect("invalid test JSON"); let exceptions = serde_json::from_reader( File::open("third-party/x509-limbo/exceptions.json") @@ -93,22 +93,22 @@ fn run_validation(tc: &Testcase) -> Result<(), String> { let leaf = EndEntityCert::try_from(&leaf_der).map_err(|e| format!("leaf cert parse failed: {e}"))?; - let intermediates: Vec<_> = tc + let intermediates = tc .untrusted_intermediates .iter() .map(|ic| cert_der_from_pem(ic)) - .collect(); + .collect::>(); - let trust_anchor_ders: Vec<_> = tc + let trust_anchor_ders = tc .trusted_certs .iter() .map(|ta| cert_der_from_pem(ta)) - .collect(); + .collect::>(); - let trust_anchors: Vec<_> = trust_anchor_ders + let trust_anchors = trust_anchor_ders .iter() .filter_map(|der| anchor_from_trusted_cert(der).ok()) - .collect(); + .collect::>(); if trust_anchors.is_empty() && !trust_anchor_ders.is_empty() { return Err("trust anchor extraction failed".into()); @@ -122,7 +122,7 @@ fn run_validation(tc: &Testcase) -> Result<(), String> { let sig_algs = rustls_aws_lc_rs::ALL_VERIFICATION_ALGS; - let crls: Vec<_> = tc + let crls = tc .crls .iter() .map(|pem| { @@ -134,8 +134,8 @@ fn run_validation(tc: &Testcase) -> Result<(), String> { .expect("CRL DER parse failed") .into() }) - .collect(); - let crls: Vec<_> = crls.iter().collect(); + .collect::>(); + let crls = crls.iter().collect::>(); let revocation_options = if !crls.is_empty() { let opts = RevocationOptionsBuilder::new(crls.as_slice()).unwrap(); From 6291a569672049595effb7e0986eca00a5c9e271 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 22 Apr 2026 14:14:22 +0200 Subject: [PATCH 2/3] tests: avoid indirection for result matching --- tests/x509_limbo.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/x509_limbo.rs b/tests/x509_limbo.rs index 6de4d2e9..05853c3a 100644 --- a/tests/x509_limbo.rs +++ b/tests/x509_limbo.rs @@ -70,7 +70,6 @@ fn evaluate_testcase(tc: &Testcase, exceptions: &HashMap) -> let validation_result = run_validation(tc); let actual_success = validation_result.is_ok(); - let expected_success = matches!(tc.expected_result, ExpectedResult::Success); if let Some(exception) = exceptions.get(tc.id.as_str()) { if actual_success == (exception.actual == "SUCCESS") { @@ -80,10 +79,10 @@ fn evaluate_testcase(tc: &Testcase, exceptions: &HashMap) -> } // Compare actual vs expected - match (expected_success, validation_result) { - (true, Ok(())) | (false, Err(_)) => Outcome::Pass, - (true, Err(err)) => Outcome::UnexpectedFailure(err), - (false, Ok(())) => Outcome::UnexpectedSuccess, + match (tc.expected_result, validation_result) { + (ExpectedResult::Success, Ok(())) | (ExpectedResult::Failure, Err(_)) => Outcome::Pass, + (ExpectedResult::Success, Err(err)) => Outcome::UnexpectedFailure(err), + (ExpectedResult::Failure, Ok(())) => Outcome::UnexpectedSuccess, } } From 853ab2842ed5277f2b0f291459496887db7804ef Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Wed, 22 Apr 2026 14:15:53 +0200 Subject: [PATCH 3/3] tests: inline trivial binding --- tests/x509_limbo.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/x509_limbo.rs b/tests/x509_limbo.rs index 05853c3a..dfeeec4c 100644 --- a/tests/x509_limbo.rs +++ b/tests/x509_limbo.rs @@ -69,10 +69,8 @@ fn evaluate_testcase(tc: &Testcase, exceptions: &HashMap) -> } let validation_result = run_validation(tc); - let actual_success = validation_result.is_ok(); - if let Some(exception) = exceptions.get(tc.id.as_str()) { - if actual_success == (exception.actual == "SUCCESS") { + if validation_result.is_ok() == (exception.actual == "SUCCESS") { return Outcome::KnownDivergence; } // If the exception no longer applies (behavior changed), fall through to normal comparison