Skip to content

Commit

Permalink
Fix clippy::manual_string_new (#1106)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmondal authored Jul 19, 2024
1 parent 9948737 commit 3992aef
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,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
build --@rules_rust//:clippy_flags=-Dwarnings,-Dclippy::uninlined_format_args,-Dclippy::manual_string_new
build --@rules_rust//:clippy.toml=//:clippy.toml

test --@rules_rust//:rustfmt.toml=//:.rustfmt.toml
Expand Down
4 changes: 2 additions & 2 deletions nativelink-scheduler/tests/simple_scheduler_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ async fn cacheable_items_join_same_action_queued_test() -> Result<(), Error> {
let action_digest = DigestInfo::new([99u8; 32], 512);

let unique_qualifier = ActionUniqueQualifier::Cachable(ActionUniqueKey {
instance_name: "".to_string(),
instance_name: String::new(),
digest: DigestInfo::zero_digest(),
digest_function: DigestHasherFunc::Sha256,
});
Expand Down Expand Up @@ -1158,7 +1158,7 @@ async fn does_not_crash_if_operation_joined_then_relaunched() -> Result<(), Erro
let action_digest = DigestInfo::new([99u8; 32], 512);

let unique_qualifier = ActionUniqueQualifier::Cachable(ActionUniqueKey {
instance_name: "".to_string(),
instance_name: String::new(),
digest: DigestInfo::zero_digest(),
digest_function: DigestHasherFunc::Sha256,
});
Expand Down
4 changes: 2 additions & 2 deletions nativelink-service/src/capabilities_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ impl Capabilities for CapabilitiesServer {
major: 2,
minor: 0,
patch: 0,
prerelease: "".to_string(),
prerelease: String::new(),
}),
high_api_version: Some(SemVer {
major: 2,
minor: 3,
patch: 0,
prerelease: "".to_string(),
prerelease: String::new(),
}),
};
Ok(Response::new(resp))
Expand Down
2 changes: 1 addition & 1 deletion nativelink-service/src/cas_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl CasServer {
// Trim the error code. Not Found is quite common and we don't want to send a large
// error (debug) message for something that is common. We resize to just the last
// message as it will be the most relevant.
e.messages.resize_with(1, || "".to_string());
e.messages.resize_with(1, String::new);
}
(e.into(), Bytes::new())
},
Expand Down
10 changes: 5 additions & 5 deletions nativelink-service/tests/cas_server_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ async fn update_existing_item() -> Result<(), Box<dyn std::error::Error>> {
digest: Some(digest),
status: Some(GrpcStatus {
code: 0, // Status Ok.
message: "".to_string(),
message: String::new(),
details: vec![],
}),
},],
Expand Down Expand Up @@ -269,7 +269,7 @@ async fn batch_read_blobs_read_two_blobs_success_one_fail() -> Result<(), Box<dy
data: VALUE1.into(),
status: Some(GrpcStatus {
code: 0, // Status Ok.
message: "".to_string(),
message: String::new(),
details: vec![],
}),
compressor: compressor::Value::Identity.into(),
Expand All @@ -279,7 +279,7 @@ async fn batch_read_blobs_read_two_blobs_success_one_fail() -> Result<(), Box<dy
data: VALUE2.into(),
status: Some(GrpcStatus {
code: 0, // Status Ok.
message: "".to_string(),
message: String::new(),
details: vec![],
}),
compressor: compressor::Value::Identity.into(),
Expand Down Expand Up @@ -577,15 +577,15 @@ async fn batch_update_blobs_two_items_existence_with_third_missing(
digest: Some(digest1),
status: Some(GrpcStatus {
code: 0, // Status Ok.
message: "".to_string(),
message: String::new(),
details: vec![],
}),
},
batch_update_blobs_response::Response {
digest: Some(digest2),
status: Some(GrpcStatus {
code: 0, // Status Ok.
message: "".to_string(),
message: String::new(),
details: vec![],
}),
}
Expand Down
2 changes: 1 addition & 1 deletion nativelink-store/src/ac_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub async fn get_size_and_decode_digest<T: Message + Default + 'static>(
// Trim the error code. Not Found is quite common and we don't want to send a large
// error (debug) message for something that is common. We resize to just the last
// message as it will be the most relevant.
err.messages.resize_with(1, || "".to_string());
err.messages.resize_with(1, String::new);
}
}
let store_data = store_data_resp?;
Expand Down
4 changes: 2 additions & 2 deletions nativelink-util/src/action_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ pub struct ExecutionMetadata {
impl Default for ExecutionMetadata {
fn default() -> Self {
Self {
worker: "".to_string(),
worker: String::new(),
queued_timestamp: SystemTime::UNIX_EPOCH,
worker_start_timestamp: SystemTime::UNIX_EPOCH,
worker_completed_timestamp: SystemTime::UNIX_EPOCH,
Expand Down Expand Up @@ -725,7 +725,7 @@ impl Default for ActionResult {
stdout_digest: DigestInfo::new([0u8; 32], 0),
stderr_digest: DigestInfo::new([0u8; 32], 0),
execution_metadata: ExecutionMetadata {
worker: "".to_string(),
worker: String::new(),
queued_timestamp: SystemTime::UNIX_EPOCH,
worker_start_timestamp: SystemTime::UNIX_EPOCH,
worker_completed_timestamp: SystemTime::UNIX_EPOCH,
Expand Down

0 comments on commit 3992aef

Please sign in to comment.