Skip to content

Commit 0b89213

Browse files
authored
ci: run rustfmt/clippy on standard crates (#5333)
1 parent 5ef7c3d commit 0b89213

File tree

9 files changed

+39
-37
lines changed

9 files changed

+39
-37
lines changed

.github/workflows/ci_rust.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,14 @@ jobs:
349349
- name: Generate
350350
run: ./${{env.ROOT_PATH}}/generate.sh --skip-tests
351351

352-
- name: Run cargo fmt
352+
- name: Run cargo fmt - extended packages
353353
run: |
354354
cargo fmt --manifest-path ${{env.ROOT_PATH}}/Cargo.toml --all -- --check
355355
356+
- name: Run cargo fmt - standard packages
357+
run: |
358+
cargo fmt --manifest-path ${{env.STANDARD_PATH}}/Cargo.toml --all -- --check
359+
356360
clippy:
357361
runs-on: ubuntu-latest
358362
steps:
@@ -384,11 +388,16 @@ jobs:
384388
run: ${{env.ROOT_PATH}}/generate.sh
385389

386390
# TODO translate json reports to in-action warnings
387-
- name: Run cargo clippy
391+
- name: Run cargo clippy - extended packages
388392
run: |
389393
cargo clippy --manifest-path ${{env.ROOT_PATH}}/Cargo.toml --all-targets -- -D warnings
390394
cargo clippy --manifest-path ${{env.ROOT_PATH}}/Cargo.toml --all-targets --all-features -- -D warnings
391395
396+
- name: Run cargo clippy - standard packages
397+
run: |
398+
cargo clippy --manifest-path ${{env.STANDARD_PATH}}/Cargo.toml --all-targets -- -D warnings
399+
cargo clippy --manifest-path ${{env.STANDARD_PATH}}/Cargo.toml --all-targets --all-features -- -D warnings
400+
392401
msrv:
393402
runs-on: ubuntu-latest
394403
steps:

bindings/rust/standard/bench/benches/handshake.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use bench::{
55
harness::TlsBenchConfig, CipherSuite, CryptoConfig, HandshakeType, KXGroup, Mode,
6-
OpenSslConnection, RustlsConnection, S2NConnection, SigType, TlsConnPair, TlsConnection
6+
OpenSslConnection, RustlsConnection, S2NConnection, SigType, TlsConnPair, TlsConnection,
77
};
88
use criterion::{
99
criterion_group, criterion_main, measurement::WallTime, BatchSize, BenchmarkGroup, Criterion,
@@ -20,17 +20,19 @@ fn bench_handshake_for_library<T>(
2020
T::Config: TlsBenchConfig,
2121
{
2222
let crypto_config = CryptoConfig::new(CipherSuite::default(), kx_group, sig_type);
23-
let client_config = &T::Config::make_config(Mode::Client, crypto_config, handshake_type).unwrap();
24-
let server_config = &T::Config::make_config(Mode::Server, crypto_config, handshake_type).unwrap();
23+
let client_config =
24+
&T::Config::make_config(Mode::Client, crypto_config, handshake_type).unwrap();
25+
let server_config =
26+
&T::Config::make_config(Mode::Server, crypto_config, handshake_type).unwrap();
2527

2628
// generate all harnesses (TlsConnPair structs) beforehand so that benchmarks
2729
// only include negotiation and not config/connection initialization
2830
bench_group.bench_function(T::name(), |b| {
2931
b.iter_batched_ref(
30-
|| -> TlsConnPair<T, T> {
32+
|| -> TlsConnPair<T, T> {
3133
if handshake_type == HandshakeType::Resumption {
3234
// generate a session ticket to store on the config
33-
let mut pair = TlsConnPair::<T, T>::from_configs(&client_config, &server_config);
35+
let mut pair = TlsConnPair::<T, T>::from_configs(client_config, server_config);
3436
pair.handshake().unwrap();
3537
pair.round_trip_transfer(&mut [0]).unwrap();
3638
}
@@ -39,13 +41,15 @@ fn bench_handshake_for_library<T>(
3941
|conn_pair| {
4042
conn_pair.handshake().unwrap();
4143
match handshake_type {
42-
HandshakeType::ServerAuth | HandshakeType::MutualAuth => assert!(!conn_pair.server.resumed_connection()),
44+
HandshakeType::ServerAuth | HandshakeType::MutualAuth => {
45+
assert!(!conn_pair.server.resumed_connection())
46+
}
4347
HandshakeType::Resumption => assert!(conn_pair.server.resumed_connection()),
4448
}
4549
},
46-
// Use "PerIteration" benchmarking, because of the way that session
50+
// Use "PerIteration" benchmarking, because of the way that session
4751
// ticket setup interacts with shared configs.
48-
// > In testing, the maximum measurement overhead from benchmarking
52+
// > In testing, the maximum measurement overhead from benchmarking
4953
// > with PerIteration is on the order of 350 nanoseconds
5054
BatchSize::PerIteration,
5155
)

bindings/rust/standard/bench/benches/resumption.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ where
7070
pub fn bench_resumption(c: &mut Criterion) {
7171
// compare resumption savings across both client and server
7272
for sig_type in [SigType::Rsa2048, SigType::Ecdsa256] {
73-
let mut bench_group = c.benchmark_group(format!("resumption-pair-{:?}", sig_type));
73+
let mut bench_group = c.benchmark_group(format!("resumption-pair-{sig_type:?}"));
7474
bench_handshake_pair::<S2NConnection>(&mut bench_group, sig_type);
7575
}
7676

7777
// only look at resumption savings for the server, specifically the work
7878
// done in the first rtt.
7979
for sig_type in [SigType::Rsa2048, SigType::Ecdsa384] {
80-
let mut bench_group = c.benchmark_group(format!("resumption-server-1rtt-{:?}", sig_type));
80+
let mut bench_group = c.benchmark_group(format!("resumption-server-1rtt-{sig_type:?}"));
8181
bench_handshake_server_1rtt::<S2NConnection>(&mut bench_group, sig_type);
8282
}
8383
}

bindings/rust/standard/bench/benches/throughput.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use bench::OpenSslConnection;
5-
use bench::RustlsConnection;
64
use bench::{
75
harness::TlsBenchConfig, CipherSuite, CryptoConfig, HandshakeType, KXGroup, Mode,
8-
S2NConnection, SigType, TlsConnPair, TlsConnection, PROFILER_FREQUENCY,
6+
OpenSslConnection, RustlsConnection, S2NConnection, SigType, TlsConnPair, TlsConnection,
97
};
108
use criterion::{
119
criterion_group, criterion_main, measurement::WallTime, BatchSize, BenchmarkGroup, Criterion,
1210
Throughput,
1311
};
14-
use pprof::criterion::{Output, PProfProfiler};
1512
use strum::IntoEnumIterator;
1613

1714
fn bench_throughput_for_library<T>(
@@ -48,7 +45,7 @@ pub fn bench_throughput_cipher_suites(c: &mut Criterion) {
4845
let mut shared_buf = [0u8; 100000];
4946

5047
for cipher_suite in CipherSuite::iter() {
51-
let mut bench_group = c.benchmark_group(format!("throughput-{:?}", cipher_suite));
48+
let mut bench_group = c.benchmark_group(format!("throughput-{cipher_suite:?}"));
5249
bench_group.throughput(Throughput::Bytes(shared_buf.len() as u64));
5350
bench_throughput_for_library::<S2NConnection>(
5451
&mut bench_group,

bindings/rust/standard/bench/src/rustls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl RustlsConfig {
7979
pkcs_8_key.into()
8080
} else {
8181
// https://docs.rs/rustls-pemfile/latest/rustls_pemfile/enum.Item.html
82-
panic!("unexpected key type: {:?}", key);
82+
panic!("unexpected key type: {key:?}");
8383
}
8484
}
8585
}

bindings/rust/standard/integration/src/features/mldsa.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ use std::{fs, path::Path, pin::Pin};
88
use tokio::net::{TcpListener, TcpStream};
99
use tokio_openssl::SslStream;
1010

11-
const TEST_PEMS_PATH: &'static str =
12-
concat!(env!("CARGO_MANIFEST_DIR"), "/../../../../tests/pems/");
11+
const TEST_PEMS_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../../../tests/pems/");
1312

1413
pub async fn get_streams() -> Result<(TcpStream, TcpStream), tokio::io::Error> {
1514
let localhost = "127.0.0.1".to_owned();
16-
let listener = TcpListener::bind(format!("{}:0", localhost)).await?;
15+
let listener = TcpListener::bind(format!("{localhost}:0")).await?;
1716
let addr = listener.local_addr()?;
1817
let client_stream = TcpStream::connect(&addr).await?;
1918
let (server_stream, _) = listener.accept().await?;

bindings/rust/standard/integration/src/network/tls_client.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ mod kms_pq {
4545
let policy = Policy::from_version("PQ-TLS-1-2-2024-10-09")?;
4646
let tls = handshake_with_domain(DOMAIN, &policy).await?;
4747

48-
assert_eq!(
49-
tls.as_ref().cipher_suite()?,
50-
"TLS_AES_256_GCM_SHA384"
51-
);
48+
assert_eq!(tls.as_ref().cipher_suite()?, "TLS_AES_256_GCM_SHA384");
5249

5350
// As of 2/5/25, some KMS hosts support ML-KEM, while other hosts still only support earlier
5451
// draft PQ KEM groups. As such, we currently assert that any KEM group was negotiated.

bindings/rust/standard/s2n-tls-hyper/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ impl Display for Error {
1919
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2020
match self {
2121
Error::InvalidScheme => write!(f, "The provided URI contains an invalid scheme."),
22-
Error::HttpError(err) => write!(f, "{}", err),
23-
Error::TlsError(err) => write!(f, "{}", err),
22+
Error::HttpError(err) => write!(f, "{err}"),
23+
Error::TlsError(err) => write!(f, "{err}"),
2424
}
2525
}
2626
}

bindings/rust/standard/s2n-tls-hyper/tests/http.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async fn test_get_request() -> Result<(), Box<dyn Error + Send + Sync>> {
4040
let client: Client<_, Empty<Bytes>> =
4141
Client::builder(TokioExecutor::new()).build(connector);
4242

43-
let uri = Uri::from_str(format!("https://localhost:{}", port).as_str())?;
43+
let uri = Uri::from_str(format!("https://localhost:{port}").as_str())?;
4444
let response = client.get(uri).await?;
4545
assert_eq!(response.status(), 200);
4646

@@ -62,9 +62,7 @@ async fn test_http_methods() -> Result<(), Box<dyn Error + Send + Sync>> {
6262
Client::builder(TokioExecutor::new()).build(connector);
6363
let request: Request<Full<Bytes>> = Request::builder()
6464
.method(method)
65-
.uri(Uri::from_str(
66-
format!("https://localhost:{}", port).as_str(),
67-
)?)
65+
.uri(Uri::from_str(format!("https://localhost:{port}").as_str())?)
6866
.body(Full::from(TEST_DATA))?;
6967

7068
let response = client.request(request).await?;
@@ -89,9 +87,7 @@ async fn test_large_request() -> Result<(), Box<dyn Error + Send + Sync>> {
8987
let client: Client<_, Full<Bytes>> = Client::builder(TokioExecutor::new()).build(connector);
9088
let request: Request<Full<Bytes>> = Request::builder()
9189
.method(Method::POST)
92-
.uri(Uri::from_str(
93-
format!("https://localhost:{}", port).as_str(),
94-
)?)
90+
.uri(Uri::from_str(format!("https://localhost:{port}").as_str())?)
9591
.body(Full::from(LARGE_TEST_DATA))?;
9692

9793
let response = client.request(request).await?;
@@ -138,7 +134,7 @@ async fn test_sni() -> Result<(), Box<dyn Error + Send + Sync>> {
138134
let client: Client<_, Empty<Bytes>> =
139135
Client::builder(TokioExecutor::new()).build(connector);
140136

141-
let uri = Uri::from_str(format!("https://{}:{}", hostname, port).as_str())?;
137+
let uri = Uri::from_str(format!("https://{hostname}:{port}").as_str())?;
142138
let response = client.get(uri).await?;
143139
assert_eq!(response.status(), 200);
144140

@@ -288,7 +284,7 @@ async fn http2() -> Result<(), Box<dyn Error + Send + Sync>> {
288284
let client: Client<_, Empty<Bytes>> =
289285
Client::builder(TokioExecutor::new()).build(connector);
290286

291-
let uri = Uri::from_str(format!("https://localhost:{}", port).as_str())?;
287+
let uri = Uri::from_str(format!("https://localhost:{port}").as_str())?;
292288
let response = client.get(uri).await?;
293289
assert_eq!(response.status(), 200);
294290

@@ -324,7 +320,7 @@ async fn config_alpn_ignored() -> Result<(), Box<dyn Error + Send + Sync>> {
324320
let client: Client<_, Empty<Bytes>> =
325321
Client::builder(TokioExecutor::new()).build(connector);
326322

327-
let uri = Uri::from_str(format!("https://localhost:{}", port).as_str())?;
323+
let uri = Uri::from_str(format!("https://localhost:{port}").as_str())?;
328324
let response = client.get(uri).await?;
329325
assert_eq!(response.status(), 200);
330326

0 commit comments

Comments
 (0)