about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2025-07-13 07:21:22 +0200
committerGitHub <noreply@github.com>2025-07-13 07:21:22 +0200
commitd607b944e48e1ea8c501e6bc1fb7360e1400aa7d (patch)
tree4e08d4c3a30451b77ac5bf6b0af6a81846dce735 /src
parentb0e559a9766b79700cc57dfd38c37121cf219d0f (diff)
parentd004abb4d3d7a4c50c54ffb3c4f227ff0d689f03 (diff)
downloadrust-d607b944e48e1ea8c501e6bc1fb7360e1400aa7d.tar.gz
rust-d607b944e48e1ea8c501e6bc1fb7360e1400aa7d.zip
Rollup merge of #143798 - Shourya742:2025-07-11-remove-format-short-command-trait, r=Kobzol
Remove format short command trait

Since we no longer have traces of the vanilla command, and we're already implementing format_short_command for CommandFingerprint, we can use it directly from the fingerprint. This PR removes the standalone format_short_command trait and moves its implementation under CommandFingerprint.
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/src/utils/exec.rs29
-rw-r--r--src/bootstrap/src/utils/tracing.rs4
2 files changed, 5 insertions, 28 deletions
diff --git a/src/bootstrap/src/utils/exec.rs b/src/bootstrap/src/utils/exec.rs
index c5bafda88c4..ebc18f11a05 100644
--- a/src/bootstrap/src/utils/exec.rs
+++ b/src/bootstrap/src/utils/exec.rs
@@ -76,8 +76,10 @@ pub struct CommandFingerprint {
     cwd: Option<PathBuf>,
 }
 
-impl FormatShortCmd for CommandFingerprint {
-    fn format_short_cmd(&self) -> String {
+impl CommandFingerprint {
+    /// Helper method to format both Command and BootstrapCommand as a short execution line,
+    /// without all the other details (e.g. environment variables).
+    pub fn format_short_cmd(&self) -> String {
         let program = Path::new(&self.program);
         let mut line = vec![program.file_name().unwrap().to_str().unwrap().to_owned()];
         line.extend(self.args.iter().map(|arg| arg.to_string_lossy().into_owned()));
@@ -545,29 +547,6 @@ impl Default for CommandOutput {
     }
 }
 
-/// Helper trait to format both Command and BootstrapCommand as a short execution line,
-/// without all the other details (e.g. environment variables).
-pub trait FormatShortCmd {
-    fn format_short_cmd(&self) -> String;
-}
-
-#[cfg(feature = "tracing")]
-impl FormatShortCmd for BootstrapCommand {
-    fn format_short_cmd(&self) -> String {
-        self.command.format_short_cmd()
-    }
-}
-
-#[cfg(feature = "tracing")]
-impl FormatShortCmd for Command {
-    fn format_short_cmd(&self) -> String {
-        let program = Path::new(self.get_program());
-        let mut line = vec![program.file_name().unwrap().to_str().unwrap()];
-        line.extend(self.get_args().map(|arg| arg.to_str().unwrap()));
-        line.join(" ")
-    }
-}
-
 #[derive(Clone, Default)]
 pub struct ExecutionContext {
     dry_run: DryRun,
diff --git a/src/bootstrap/src/utils/tracing.rs b/src/bootstrap/src/utils/tracing.rs
index 99849341dc3..109407bc5f2 100644
--- a/src/bootstrap/src/utils/tracing.rs
+++ b/src/bootstrap/src/utils/tracing.rs
@@ -52,13 +52,11 @@ macro_rules! error {
 macro_rules! trace_cmd {
     ($cmd:expr) => {
         {
-            use $crate::utils::exec::FormatShortCmd;
-
             ::tracing::span!(
                 target: "COMMAND",
                 ::tracing::Level::TRACE,
                 "executing command",
-                cmd = $cmd.format_short_cmd(),
+                cmd = $cmd.fingerprint().format_short_cmd(),
                 full_cmd = ?$cmd
             ).entered()
         }