Skip to content

Commit 580f925

Browse files
committed
Resolve clippy lints, change to #[expect]
All remaining clippy lints are converted to `#[expect]` with reasons attached. The only exceptions are a handful of `#[allow]` attributes in testing due to the manner in which tests are compiled.
1 parent e76a89d commit 580f925

File tree

20 files changed

+92
-97
lines changed

20 files changed

+92
-97
lines changed

nativelink-macro/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ pub fn nativelink_test(attr: TokenStream, item: TokenStream) -> TokenStream {
3131

3232
let expanded = quote! {
3333
#(#fn_attr)*
34-
#[allow(clippy::disallowed_methods)]
34+
#[expect(
35+
clippy::disallowed_methods,
36+
reason = "`tokio::test` uses `tokio::runtime::Runtime::block_on`"
37+
)]
3538
#[tokio::test(#attr)]
3639
async fn #fn_name(#fn_inputs) #fn_output {
3740
// Error means already initialized, which is ok.

nativelink-scheduler/tests/utils/mock_scheduler.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@ use nativelink_util::operation_state_manager::{
2424
};
2525
use tokio::sync::{mpsc, Mutex};
2626

27-
#[allow(clippy::large_enum_variant)]
28-
#[allow(dead_code)] // See https://github.com/rust-lang/rust/issues/46379
27+
#[expect(
28+
clippy::large_enum_variant,
29+
reason = "testing, so this doesn't really matter"
30+
)]
31+
#[allow(dead_code, reason = "https://github.com/rust-lang/rust/issues/46379")]
2932
enum ActionSchedulerCalls {
3033
GetGetKnownProperties(String),
3134
AddAction((OperationId, ActionInfo)),
3235
FilterOperations(OperationFilter),
3336
}
3437

35-
#[allow(dead_code)] // See https://github.com/rust-lang/rust/issues/46379
38+
#[allow(dead_code, reason = "https://github.com/rust-lang/rust/issues/46379")]
3639
enum ActionSchedulerReturns {
3740
GetGetKnownProperties(Result<Vec<String>, Error>),
3841
AddAction(Result<Box<dyn ActionStateResult>, Error>),
@@ -66,7 +69,7 @@ impl MockActionScheduler {
6669
}
6770
}
6871

69-
#[allow(dead_code)] // See https://github.com/rust-lang/rust/issues/46379
72+
#[allow(dead_code, reason = "https://github.com/rust-lang/rust/issues/46379")]
7073
pub async fn expect_get_known_properties(&self, result: Result<Vec<String>, Error>) -> String {
7174
let mut rx_call_lock = self.rx_call.lock().await;
7275
let ActionSchedulerCalls::GetGetKnownProperties(req) = rx_call_lock

nativelink-scheduler/tests/utils/scheduler_utils.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ pub struct TokioWatchActionStateResult {
5656
}
5757

5858
impl TokioWatchActionStateResult {
59-
// Note: This function is only used in tests, but for some reason
60-
// rust doesn't detect it as used.
61-
#[allow(dead_code)]
59+
#[allow(dead_code, reason = "https://github.com/rust-lang/rust/issues/46379")]
6260
pub const fn new(
6361
client_operation_id: OperationId,
6462
action_info: Arc<ActionInfo>,

nativelink-service/src/ac_server.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ impl AcServer {
169169

170170
#[tonic::async_trait]
171171
impl ActionCache for AcServer {
172-
#[allow(clippy::blocks_in_conditions)]
173172
#[instrument(
174173
ret(level = Level::INFO),
175174
level = Level::ERROR,
@@ -199,7 +198,6 @@ impl ActionCache for AcServer {
199198
resp
200199
}
201200

202-
#[allow(clippy::blocks_in_conditions)]
203201
#[instrument(
204202
err,
205203
ret(level = Level::INFO),

nativelink-service/src/bep_server.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ type PublishBuildToolEventStreamStream = Pin<
202202
impl PublishBuildEvent for BepServer {
203203
type PublishBuildToolEventStreamStream = PublishBuildToolEventStreamStream;
204204

205-
#[allow(clippy::blocks_in_conditions)]
206205
#[instrument(
207206
err,
208207
ret(level = Level::INFO),
@@ -219,7 +218,6 @@ impl PublishBuildEvent for BepServer {
219218
.map_err(Error::into)
220219
}
221220

222-
#[allow(clippy::blocks_in_conditions)]
223221
#[instrument(
224222
err,
225223
level = Level::ERROR,

nativelink-service/src/bytestream_server.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,6 @@ impl ByteStreamServer {
580580
impl ByteStream for ByteStreamServer {
581581
type ReadStream = ReadStream;
582582

583-
#[allow(clippy::blocks_in_conditions)]
584583
#[instrument(
585584
err,
586585
level = Level::ERROR,
@@ -637,7 +636,6 @@ impl ByteStream for ByteStreamServer {
637636
resp
638637
}
639638

640-
#[allow(clippy::blocks_in_conditions)]
641639
#[instrument(
642640
err,
643641
level = Level::ERROR,
@@ -697,7 +695,6 @@ impl ByteStream for ByteStreamServer {
697695
resp
698696
}
699697

700-
#[allow(clippy::blocks_in_conditions)]
701698
#[instrument(
702699
err,
703700
ret(level = Level::INFO),

nativelink-service/src/capabilities_server.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ impl CapabilitiesServer {
9191

9292
#[tonic::async_trait]
9393
impl Capabilities for CapabilitiesServer {
94-
#[allow(clippy::blocks_in_conditions)]
9594
#[instrument(
9695
err,
9796
ret(level = Level::INFO),

nativelink-service/src/cas_server.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ impl CasServer {
305305
impl ContentAddressableStorage for CasServer {
306306
type GetTreeStream = GetTreeStream;
307307

308-
#[allow(clippy::blocks_in_conditions)]
309308
#[instrument(
310309
err,
311310
ret(level = Level::INFO),
@@ -332,7 +331,6 @@ impl ContentAddressableStorage for CasServer {
332331
resp
333332
}
334333

335-
#[allow(clippy::blocks_in_conditions)]
336334
#[instrument(
337335
err,
338336
ret(level = Level::INFO),
@@ -359,7 +357,6 @@ impl ContentAddressableStorage for CasServer {
359357
resp
360358
}
361359

362-
#[allow(clippy::blocks_in_conditions)]
363360
#[instrument(
364361
err,
365362
ret(level = Level::INFO),
@@ -386,7 +383,6 @@ impl ContentAddressableStorage for CasServer {
386383
resp
387384
}
388385

389-
#[allow(clippy::blocks_in_conditions)]
390386
#[instrument(
391387
err,
392388
level = Level::ERROR,

nativelink-service/src/execution_server.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ impl Execution for ExecutionServer {
321321
type ExecuteStream = ExecuteStream;
322322
type WaitExecutionStream = ExecuteStream;
323323

324-
#[allow(clippy::blocks_in_conditions)]
325324
#[instrument(
326325
err,
327326
level = Level::ERROR,
@@ -349,7 +348,6 @@ impl Execution for ExecutionServer {
349348
resp
350349
}
351350

352-
#[allow(clippy::blocks_in_conditions)]
353351
#[instrument(
354352
err,
355353
level = Level::ERROR,

nativelink-service/src/worker_api_server.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ impl WorkerApiServer {
256256
impl WorkerApi for WorkerApiServer {
257257
type ConnectWorkerStream = ConnectWorkerStream;
258258

259-
#[allow(clippy::blocks_in_conditions)]
260259
#[instrument(
261260
err,
262261
level = Level::ERROR,
@@ -277,7 +276,6 @@ impl WorkerApi for WorkerApiServer {
277276
resp
278277
}
279278

280-
#[allow(clippy::blocks_in_conditions)]
281279
#[instrument(
282280
err,
283281
ret(level = Level::INFO),
@@ -294,7 +292,6 @@ impl WorkerApi for WorkerApiServer {
294292
.map_err(Into::into)
295293
}
296294

297-
#[allow(clippy::blocks_in_conditions)]
298295
#[instrument(
299296
err,
300297
ret(level = Level::INFO),
@@ -311,7 +308,6 @@ impl WorkerApi for WorkerApiServer {
311308
.map_err(Into::into)
312309
}
313310

314-
#[allow(clippy::blocks_in_conditions)]
315311
#[instrument(
316312
err,
317313
ret(level = Level::INFO),

0 commit comments

Comments
 (0)