Skip to content

Commit 6e70a2d

Browse files
committed
Apply nightly clippy suggestions
1 parent c4860a5 commit 6e70a2d

3 files changed

Lines changed: 12 additions & 15 deletions

File tree

examples/print-trust-anchors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() -> Result<(), Box<dyn Error>> {
77
for cert in rustls_native_certs::load_native_certs().expect("could not load platform certs") {
88
match parse_x509_certificate(cert.as_ref()) {
99
Ok((_, cert)) => println!("{}", cert.tbs_certificate.subject),
10-
Err(e) => eprintln!("error parsing certificate: {}", e),
10+
Err(e) => eprintln!("error parsing certificate: {e}"),
1111
};
1212
}
1313
Ok(())

tests/compare_mozilla.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn stringify_x500name(subject: &Der<'_>) -> String {
2626

2727
let mut pair = untrusted::Reader::new(pair);
2828
let oid = der::expect_tag_and_get_value(&mut pair, der::Tag::OID).unwrap();
29-
let (valuety, value) = der::read_tag_and_get_value(&mut pair).unwrap();
29+
let (value_ty, value) = der::read_tag_and_get_value(&mut pair).unwrap();
3030

3131
let name = match oid.as_slice_less_safe() {
3232
[0x55, 0x04, 0x03] => "CN",
@@ -41,16 +41,16 @@ fn stringify_x500name(subject: &Der<'_>) -> String {
4141
[0x55, 0x04, 0x61] => "organizationIdentifier",
4242
[0x09, 0x92, 0x26, 0x89, 0x93, 0xf2, 0x2c, 0x64, 0x01, 0x19] => "domainComponent",
4343
[0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01] => "emailAddress",
44-
_ => panic!("unhandled x500 attr {:?}", oid),
44+
_ => panic!("unhandled x500 attr {oid:?}"),
4545
};
4646

47-
let str_value = match valuety {
47+
let str_value = match value_ty {
4848
// PrintableString, UTF8String, TeletexString or IA5String
4949
0x0c | 0x13 | 0x14 | 0x16 => std::str::from_utf8(value.as_slice_less_safe()).unwrap(),
50-
_ => panic!("unhandled x500 value type {:?}", valuety),
50+
_ => panic!("unhandled x500 value type {value_ty:?}"),
5151
};
5252

53-
parts.push(format!("{}={}", name, str_value));
53+
parts.push(format!("{name}={str_value}"));
5454
}
5555

5656
parts.join(", ")
@@ -90,8 +90,7 @@ fn test_does_not_have_many_roots_unknown_by_mozilla() {
9090
println!("mozilla: {:?}", mozilla.len());
9191
println!("native: {:?}", native.certs.len());
9292
println!(
93-
"{:?} anchors present in native set but not mozilla ({}%)",
94-
missing_in_moz_roots,
93+
"{missing_in_moz_roots:?} anchors present in native set but not mozilla ({}%)",
9594
diff * 100.
9695
);
9796
assert!(diff < threshold, "too many unknown roots");
@@ -131,8 +130,7 @@ fn test_contains_most_roots_known_by_mozilla() {
131130
println!("mozilla: {:?}", mozilla.len());
132131
println!("native: {:?}", native.certs.len());
133132
println!(
134-
"{:?} anchors present in mozilla set but not native ({}%)",
135-
missing_in_native_roots,
133+
"{missing_in_native_roots:?} anchors present in mozilla set but not native ({}%)",
136134
diff * 100.
137135
);
138136
assert!(diff < threshold, "too many missing roots");

tests/smoketests.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,22 @@ fn check_site_with_roots(
5151
.to_owned(),
5252
)
5353
.unwrap();
54-
let mut sock = TcpStream::connect(format!("{}:443", domain)).unwrap();
54+
let mut sock = TcpStream::connect(format!("{domain}:443")).unwrap();
5555
let mut tls = rustls::Stream::new(&mut conn, &mut sock);
5656
let result = tls.write_all(
5757
format!(
5858
"GET / HTTP/1.1\r\n\
59-
Host: {}\r\n\
59+
Host: {domain}\r\n\
6060
Connection: close\r\n\
6161
Accept-Encoding: identity\r\n\
62-
\r\n",
63-
domain
62+
\r\n"
6463
)
6564
.as_bytes(),
6665
);
6766
match result {
6867
Ok(()) => (),
6968
Err(e) if e.kind() == ErrorKind::InvalidData => return Err(()), // TLS error
70-
Err(e) => panic!("{}", e),
69+
Err(e) => panic!("{e}"),
7170
}
7271
let mut plaintext = [0u8; 1024];
7372
let len = tls.read(&mut plaintext).unwrap();

0 commit comments

Comments
 (0)