From 775e3d3b8ac94157b683747b64cdd260cc4b8152 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Thu, 17 Sep 2026 16:27:34 +0200 Subject: [PATCH] fmt --- src/build/mod.rs | 24 +++++++++++++++--------- src/package_info.rs | 19 +++++++++---------- src/pull.rs | 12 ++++-------- src/test_support.rs | 4 ++-- src/ui.rs | 4 +--- 5 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/build/mod.rs b/src/build/mod.rs index 8ac08b5..1df39c4 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -212,8 +212,10 @@ pub fn run_source_build( ) -> Result> { // Without a live UI, test runs still capture command output into the // per-test log file instead of letting it inherit the terminal - let sink: Option> = - ui.as_ref().map(|u| u.sink()).or_else(crate::test_support::subprocess_sink); + let sink: Option> = ui + .as_ref() + .map(|u| u.sink()) + .or_else(crate::test_support::subprocess_sink); // ------------------------------------------------------------------ // 1. Sanity checks // ------------------------------------------------------------------ @@ -1315,10 +1317,9 @@ mod differential_tests { } fn copy_path(src: &Path, dst_root: &Path) { - let status = crate::test_support::run_logged( - Command::new("cp").arg("-a").arg(src).arg(dst_root), - ) - .expect("run cp -a"); + let status = + crate::test_support::run_logged(Command::new("cp").arg("-a").arg(src).arg(dst_root)) + .expect("run cp -a"); assert!( status.success(), "cp -a {} {} failed", @@ -1329,9 +1330,14 @@ mod differential_tests { fn run_dpkg(tree: &Path) { let status = crate::test_support::run_logged( - Command::new("dpkg-buildpackage") - .current_dir(tree) - .args(["-S", "-I", "-i", "-nc", "-d", "--no-sign"]), + Command::new("dpkg-buildpackage").current_dir(tree).args([ + "-S", + "-I", + "-i", + "-nc", + "-d", + "--no-sign", + ]), ) .expect("failed to run dpkg-buildpackage (is dpkg-dev installed?)"); assert!(status.success(), "dpkg-buildpackage failed"); diff --git a/src/package_info.rs b/src/package_info.rs index 368979c..c44f92d 100644 --- a/src/package_info.rs +++ b/src/package_info.rs @@ -645,7 +645,8 @@ async fn fetch_index_bytes(url: &str) -> Result, String> { Err(e) => { last_error = e.to_string(); log::debug!("fetch of '{url}' failed (attempt {attempt}/{ATTEMPTS}): {last_error}"); - tokio::time::sleep(std::time::Duration::from_millis(300 * u64::from(attempt))).await; + tokio::time::sleep(std::time::Duration::from_millis(300 * u64::from(attempt))) + .await; } Ok(response) => { if !response.status().is_success() { @@ -659,9 +660,9 @@ async fn fetch_index_bytes(url: &str) -> Result, String> { log::debug!( "empty body for '{url}' (attempt {attempt}/{ATTEMPTS}), retrying" ); - tokio::time::sleep( - std::time::Duration::from_millis(300 * u64::from(attempt)), - ) + tokio::time::sleep(std::time::Duration::from_millis( + 300 * u64::from(attempt), + )) .await; } Ok(bytes) => return Ok(bytes.to_vec()), @@ -671,9 +672,9 @@ async fn fetch_index_bytes(url: &str) -> Result, String> { log::debug!( "reading the body of '{url}' failed (attempt {attempt}/{ATTEMPTS}): {last_error}" ); - tokio::time::sleep( - std::time::Duration::from_millis(300 * u64::from(attempt)), - ) + tokio::time::sleep(std::time::Duration::from_millis( + 300 * u64::from(attempt), + )) .await; } } @@ -952,10 +953,8 @@ mod tests { let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap(); let addr = listener.local_addr().unwrap(); std::thread::spawn(move || { - let mut served = 0usize; - for stream in listener.incoming().flatten() { + for (served, stream) in listener.incoming().flatten().enumerate() { let index = served.min(responses.len() - 1); - served += 1; let mut stream = stream; // Drain the request first: closing with unread inbound data // would send a TCP RST and destroy the response in flight diff --git a/src/pull.rs b/src/pull.rs index 7ba7d0a..fc4c18f 100644 --- a/src/pull.rs +++ b/src/pull.rs @@ -320,18 +320,14 @@ async fn download_file_checksum( match download_file_checksum_once(url, checksum, algo, target_dir, progress).await { Ok(()) => return Ok(()), Err(e) => { - log::warn!( - "download of '{url}' failed (attempt {attempt}/{ATTEMPTS}): {e}" - ); + log::warn!("download of '{url}' failed (attempt {attempt}/{ATTEMPTS}): {e}"); last_error = e; - tokio::time::sleep(std::time::Duration::from_millis(500 * u64::from(attempt))).await; + tokio::time::sleep(std::time::Duration::from_millis(500 * u64::from(attempt))) + .await; } } } - Err(format!( - "downloading '{url}' failed after {ATTEMPTS} attempts: {last_error}" - ) - .into()) + Err(format!("downloading '{url}' failed after {ATTEMPTS} attempts: {last_error}").into()) } /// One download attempt of [`download_file_checksum`], verifying the diff --git a/src/test_support.rs b/src/test_support.rs index 9ee0142..79956f4 100644 --- a/src/test_support.rs +++ b/src/test_support.rs @@ -65,6 +65,8 @@ mod imp { pub(crate) struct SuppressFailuresStub; } +pub(crate) use imp::*; + #[cfg(test)] mod imp { use std::collections::HashMap; @@ -482,5 +484,3 @@ mod imp { .unwrap_or_else(|| "".to_string()) } } - -pub(crate) use imp::*; diff --git a/src/ui.rs b/src/ui.rs index 54052da..ba839a5 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -9,11 +9,9 @@ pub mod logfmt; /// yes/no confirmation pub mod prompt; -use indicatif::{ - MultiProgress, ProgressBar, ProgressStyle, -}; #[cfg(test)] use indicatif::ProgressDrawTarget; +use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; use std::path::Path; use std::time::Duration;