Skip to content

Commit 8d97af7

Browse files
authored
Resolve clippy lints, change to #[expect] (#1661)
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 12b24be commit 8d97af7

27 files changed

+107
-108
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-proto/gen_lib_rs_tool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@
3838
// `bazel run nativelink-proto:update_protos`
3939
4040
#![allow(
41+
unknown_lints,
4142
clippy::default_trait_access,
4243
clippy::doc_lazy_continuation,
4344
clippy::doc_markdown,
4445
clippy::large_enum_variant,
4546
clippy::missing_const_for_fn,
47+
clippy::doc_overindented_list_items,
4648
rustdoc::invalid_html_tags
4749
)]
4850
"""

nativelink-proto/genproto/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
// `bazel run nativelink-proto:update_protos`
1818

1919
#![allow(
20+
unknown_lints,
2021
clippy::default_trait_access,
2122
clippy::doc_lazy_continuation,
2223
clippy::doc_markdown,
2324
clippy::large_enum_variant,
2425
clippy::missing_const_for_fn,
26+
clippy::doc_overindented_list_items,
2527
rustdoc::invalid_html_tags
2628
)]
2729

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,

0 commit comments

Comments
 (0)