Skip to content

Commit

Permalink
Fix clippy::default_trait_access (TraceMachina#1500)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmondal authored Nov 27, 2024
1 parent c458871 commit cbc86c6
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ build --aspects=@rules_rust//rust:defs.bzl%rustfmt_aspect
build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect

# TODO(aaronmondal): Extend these flags until we can run with clippy::pedantic.
build --@rules_rust//:clippy_flags=-Dwarnings,-Dclippy::uninlined_format_args,-Dclippy::manual_string_new,-Dclippy::manual_let_else,-Dclippy::single_match_else,-Dclippy::redundant_closure_for_method_calls,-Dclippy::semicolon_if_nothing_returned,-Dclippy::unreadable_literal,-Dclippy::range_plus_one,-Dclippy::inconsistent_struct_constructor,-Dclippy::match_wildcard_for_single_variants,-Dclippy::implicit_clone,-Dclippy::needless_pass_by_value,-Dclippy::explicit_deref_methods,-Dclippy::trivially_copy_pass_by_ref,-Dclippy::unnecessary_wraps,-Dclippy::cast_lossless,-Dclippy::map_unwrap_or,-Dclippy::ref_as_ptr,-Dclippy::inline_always,-Dclippy::redundant_else,-Dclippy::return_self_not_must_use,-Dclippy::match_same_arms,-Dclippy::explicit_iter_loop,-Dclippy::items_after_statements,-Dclippy::explicit_into_iter_loop,-Dclippy::stable_sort_primitive,-Dclippy::ptr_as_ptr,-Dclippy::needless_raw_string_hashes
build --@rules_rust//:clippy_flags=-Dwarnings,-Dclippy::uninlined_format_args,-Dclippy::manual_string_new,-Dclippy::manual_let_else,-Dclippy::single_match_else,-Dclippy::redundant_closure_for_method_calls,-Dclippy::semicolon_if_nothing_returned,-Dclippy::unreadable_literal,-Dclippy::range_plus_one,-Dclippy::inconsistent_struct_constructor,-Dclippy::match_wildcard_for_single_variants,-Dclippy::implicit_clone,-Dclippy::needless_pass_by_value,-Dclippy::explicit_deref_methods,-Dclippy::trivially_copy_pass_by_ref,-Dclippy::unnecessary_wraps,-Dclippy::cast_lossless,-Dclippy::map_unwrap_or,-Dclippy::ref_as_ptr,-Dclippy::inline_always,-Dclippy::redundant_else,-Dclippy::return_self_not_must_use,-Dclippy::match_same_arms,-Dclippy::explicit_iter_loop,-Dclippy::items_after_statements,-Dclippy::explicit_into_iter_loop,-Dclippy::stable_sort_primitive,-Dclippy::ptr_as_ptr,-Dclippy::needless_raw_string_hashes,-Dclippy::default_trait_access
build --@rules_rust//:clippy.toml=//:clippy.toml

test --@rules_rust//:rustfmt.toml=//:.rustfmt.toml
Expand Down
2 changes: 2 additions & 0 deletions nativelink-proto/gen_lib_rs_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
// *** DO NOT MODIFY ***
// This file is auto-generated. To update it, run:
// `bazel run nativelink-proto:update_protos`
#![allow(clippy::default_trait_access)]
"""


Expand Down
2 changes: 2 additions & 0 deletions nativelink-proto/genproto/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// This file is auto-generated. To update it, run:
// `bazel run nativelink-proto:update_protos`

#![allow(clippy::default_trait_access)]

pub mod build {
pub mod bazel {
pub mod remote {
Expand Down
2 changes: 1 addition & 1 deletion nativelink-scheduler/src/cache_lookup_scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl CacheLookupScheduler {
Ok(Self {
ac_store,
action_scheduler,
inflight_cache_checks: Default::default(),
inflight_cache_checks: Arc::default(),
})
}

Expand Down
11 changes: 6 additions & 5 deletions nativelink-service/tests/worker_api_server_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};

use async_lock::Mutex as AsyncMutex;
use async_trait::async_trait;
use bytes::Bytes;
use nativelink_config::cas_server::WorkerApiConfig;
use nativelink_config::schedulers::WorkerAllocationStrategy;
use nativelink_error::{Error, ResultExt};
Expand Down Expand Up @@ -428,7 +429,7 @@ pub async fn execution_response_success_test() -> Result<(), Box<dyn std::error:
path: "some path1".to_string(),
digest: Some(DigestInfo::new([8u8; 32], 124).into()),
is_executable: true,
contents: Default::default(), // We don't implement this.
contents: Bytes::default(), // We don't implement this.
node_properties: None,
}],
output_file_symlinks: vec![OutputSymlink {
Expand All @@ -446,11 +447,11 @@ pub async fn execution_response_success_test() -> Result<(), Box<dyn std::error:
tree_digest: Some(DigestInfo::new([12u8; 32], 124).into()),
is_topologically_sorted: false,
}],
output_directory_symlinks: Default::default(), // Bazel deprecated this.
output_directory_symlinks: Vec::default(), // Bazel deprecated this.
exit_code: 5,
stdout_raw: Default::default(), // We don't implement this.
stdout_raw: Bytes::default(), // We don't implement this.
stdout_digest: Some(DigestInfo::new([10u8; 32], 124).into()),
stderr_raw: Default::default(), // We don't implement this.
stderr_raw: Bytes::default(), // We don't implement this.
stderr_digest: Some(DigestInfo::new([11u8; 32], 124).into()),
execution_metadata: Some(ExecutedActionMetadata {
worker: test_context.worker_id.to_string(),
Expand All @@ -474,7 +475,7 @@ pub async fn execution_response_success_test() -> Result<(), Box<dyn std::error:
status: Some(ProtoStatus {
code: 9,
message: "foo".to_string(),
details: Default::default(),
details: Vec::default(),
}),
server_logs,
message: "TODO(blaise.bruer) We should put a reference something like bb_browser"
Expand Down
6 changes: 3 additions & 3 deletions nativelink-store/tests/existence_store_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async fn simple_exist_cache_test() -> Result<(), Error> {
const VALUE: &str = "123";
let spec = ExistenceCacheSpec {
backend: StoreSpec::noop(NoopSpec::default()), // Note: Not used.
eviction_policy: Default::default(),
eviction_policy: Option::default(),
};
let inner_store = Store::new(MemoryStore::new(&MemorySpec::default()));
let store = ExistenceCacheStore::new(&spec, inner_store.clone());
Expand Down Expand Up @@ -72,7 +72,7 @@ async fn update_flags_existance_cache_test() -> Result<(), Error> {
const VALUE: &str = "123";
let spec = ExistenceCacheSpec {
backend: StoreSpec::noop(NoopSpec::default()),
eviction_policy: Default::default(),
eviction_policy: Option::default(),
};
let inner_store = Store::new(MemoryStore::new(&MemorySpec::default()));
let store = ExistenceCacheStore::new(&spec, inner_store.clone());
Expand All @@ -95,7 +95,7 @@ async fn get_part_caches_if_exact_size_set() -> Result<(), Error> {
const VALUE: &str = "123";
let spec = ExistenceCacheSpec {
backend: StoreSpec::noop(NoopSpec::default()),
eviction_policy: Default::default(),
eviction_policy: Option::default(),
};
let inner_store = Store::new(MemoryStore::new(&MemorySpec::default()));
let digest = DigestInfo::try_new(VALID_HASH1, 3).unwrap();
Expand Down
12 changes: 6 additions & 6 deletions nativelink-util/src/action_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,10 +707,10 @@ pub struct ActionResult {
impl Default for ActionResult {
fn default() -> Self {
ActionResult {
output_files: Default::default(),
output_folders: Default::default(),
output_directory_symlinks: Default::default(),
output_file_symlinks: Default::default(),
output_files: Vec::default(),
output_folders: Vec::default(),
output_directory_symlinks: Vec::default(),
output_file_symlinks: Vec::default(),
exit_code: INTERNAL_ERROR_EXIT_CODE,
stdout_digest: DigestInfo::new([0u8; 32], 0),
stderr_digest: DigestInfo::new([0u8; 32], 0),
Expand All @@ -726,7 +726,7 @@ impl Default for ActionResult {
output_upload_start_timestamp: SystemTime::UNIX_EPOCH,
output_upload_completed_timestamp: SystemTime::UNIX_EPOCH,
},
server_logs: Default::default(),
server_logs: HashMap::default(),
error: None,
message: String::new(),
}
Expand Down Expand Up @@ -974,7 +974,7 @@ impl TryFrom<ProtoActionResult> for ActionResult {
.execution_metadata
.err_tip(|| "Expected execution_metadata to be set on ExecuteResponse msg")?
.try_into()?,
server_logs: Default::default(),
server_logs: HashMap::default(),
error: None,
message: String::new(),
})
Expand Down
5 changes: 3 additions & 2 deletions nativelink-worker/tests/running_actions_manager_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use nativelink_proto::build::bazel::remote::execution::v2::{
use nativelink_proto::com::github::trace_machina::nativelink::remote_execution::{
HistoricalExecuteResponse, StartExecute,
};
use nativelink_proto::google::rpc::Status;
use nativelink_store::ac_utils::{get_and_decode_digest, serialize_and_upload_message};
use nativelink_store::fast_slow_store::FastSlowStore;
use nativelink_store::filesystem_store::FilesystemStore;
Expand Down Expand Up @@ -2119,7 +2120,7 @@ async fn success_does_cache_in_historical_results() -> Result<(), Box<dyn std::e
action_digest: Some(action_digest.into()),
execute_response: Some(ExecuteResponse {
result: Some(action_result.into()),
status: Some(Default::default()),
status: Some(Status::default()),
..Default::default()
}),
},
Expand Down Expand Up @@ -3272,7 +3273,7 @@ async fn running_actions_manager_respects_action_timeout() -> Result<(), Box<dyn
let running_actions_manager = Arc::new(RunningActionsManagerImpl::new_with_callbacks(
RunningActionsManagerArgs {
root_action_directory,
execution_configuration: Default::default(),
execution_configuration: ExecutionConfiguration::default(),
cas_store: cas_store.clone(),
ac_store: Some(Store::new(ac_store.clone())),
historical_store: Store::new(cas_store.clone()),
Expand Down

0 comments on commit cbc86c6

Please sign in to comment.