From 88899ba35c16e3e90623cb834691afac08ce3497 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Fri, 27 Jan 2023 08:43:11 -0700 Subject: [PATCH] fix: clippy lints from Rust v1.67.0 release (#99) * fix clippy::uninlined_format_args * fix clippy::seek_to_start_instead_of_rewind --- ddcommon/src/azure_app_services.rs | 5 +---- ddcommon/src/container_id.rs | 6 ++---- ddtelemetry/src/ipc/platform/unix/mod.rs | 4 +--- profiling/tests/wordpress.rs | 3 +-- tools/src/bin/dedup_headers.rs | 2 +- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/ddcommon/src/azure_app_services.rs b/ddcommon/src/azure_app_services.rs index 0206e8982..ab361c5e1 100644 --- a/ddcommon/src/azure_app_services.rs +++ b/ddcommon/src/azure_app_services.rs @@ -104,10 +104,7 @@ impl AzureMetadata { ) -> Option { match (subscription_id, site_name, resource_group) { (Some(id_sub), Some(sitename), Some(res_grp)) => Some( - format!( - "/subscriptions/{}/resourcegroups/{}/providers/microsoft.web/sites/{}", - id_sub, res_grp, sitename - ) + format!("/subscriptions/{id_sub}/resourcegroups/{res_grp}/providers/microsoft.web/sites/{sitename}") .to_lowercase(), ), _ => None, diff --git a/ddcommon/src/container_id.rs b/ddcommon/src/container_id.rs index b116d0ef4..d854b1af6 100644 --- a/ddcommon/src/container_id.rs +++ b/ddcommon/src/container_id.rs @@ -51,8 +51,7 @@ const TASK_SOURCE: &str = r"[0-9a-f]{32}-\d+"; lazy_static! { static ref LINE_REGEX: Regex = Regex::new(r"^\d+:[^:]*:(.+)$").unwrap(); static ref CONTAINER_REGEX: Regex = Regex::new(&format!( - r"({}|{}|{})(?:.scope)? *$", - UUID_SOURCE, CONTAINER_SOURCE, TASK_SOURCE + r"({UUID_SOURCE}|{CONTAINER_SOURCE}|{TASK_SOURCE})(?:.scope)? *$" )) .unwrap(); } @@ -209,8 +208,7 @@ mod tests { assert_eq!( extract_container_id(&test_root_dir.join(filename)).ok(), expected_result.map(String::from), - "testing file {}", - filename + "testing file {filename}" ); } } diff --git a/ddtelemetry/src/ipc/platform/unix/mod.rs b/ddtelemetry/src/ipc/platform/unix/mod.rs index f801c3aa0..ceab1cfa9 100644 --- a/ddtelemetry/src/ipc/platform/unix/mod.rs +++ b/ddtelemetry/src/ipc/platform/unix/mod.rs @@ -48,9 +48,7 @@ mod tests { fn get_open_file_descriptors( pid: Option, ) -> Result, io::Error> { - let proc = pid - .map(|p| format!("{}", p)) - .unwrap_or_else(|| "self".into()); + let proc = pid.map(|p| format!("{p}")).unwrap_or_else(|| "self".into()); let fds_path = std::path::Path::new("/proc").join(proc).join("fd"); let fds = std::fs::read_dir(fds_path)? diff --git a/profiling/tests/wordpress.rs b/profiling/tests/wordpress.rs index c71d4fc65..21f75b1f0 100644 --- a/profiling/tests/wordpress.rs +++ b/profiling/tests/wordpress.rs @@ -203,8 +203,7 @@ fn compare_sample(a: api::Sample, b: &api::Sample) { for (offset, (a, b)) in a.locations.iter().zip(b.locations.iter()).enumerate() { assert_eq!( a, b, - "Sample location offsets {} differ:\n{:#?}\n{:#?}", - offset, a, b + "Sample location offsets {offset} differ:\n{a:#?}\n{b:#?}" ); } } diff --git a/tools/src/bin/dedup_headers.rs b/tools/src/bin/dedup_headers.rs index 4f71decda..d3d09b298 100644 --- a/tools/src/bin/dedup_headers.rs +++ b/tools/src/bin/dedup_headers.rs @@ -30,7 +30,7 @@ fn read(f: &mut BufReader<&File>) -> String { fn write_parts(writer: &mut BufWriter<&File>, parts: &[&str]) -> io::Result<()> { writer.get_ref().set_len(0)?; - writer.seek(io::SeekFrom::Start(0))?; + writer.rewind()?; for part in parts { writer.write_all(part.as_bytes())?; }