Skip to content

Commit

Permalink
fix: clippy lints from Rust v1.67.0 release (#99)
Browse files Browse the repository at this point in the history
* fix clippy::uninlined_format_args

* fix clippy::seek_to_start_instead_of_rewind
  • Loading branch information
morrisonlevi committed Jan 27, 2023
1 parent f2d0ed0 commit 88899ba
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 14 deletions.
5 changes: 1 addition & 4 deletions ddcommon/src/azure_app_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ impl AzureMetadata {
) -> Option<String> {
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,
Expand Down
6 changes: 2 additions & 4 deletions ddcommon/src/container_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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}"
);
}
}
Expand Down
4 changes: 1 addition & 3 deletions ddtelemetry/src/ipc/platform/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ mod tests {
fn get_open_file_descriptors(
pid: Option<libc::pid_t>,
) -> Result<BTreeMap<RawFd, String>, 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)?
Expand Down
3 changes: 1 addition & 2 deletions profiling/tests/wordpress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:#?}"
);
}
}
2 changes: 1 addition & 1 deletion tools/src/bin/dedup_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())?;
}
Expand Down

0 comments on commit 88899ba

Please sign in to comment.