]> git.proxmox.com Git - cargo.git/commitdiff
Change to enumerate implementation
authorChris Field <chris@fieldrndservices.com>
Tue, 9 Feb 2021 02:35:13 +0000 (21:35 -0500)
committerChris Field <chris@fieldrndservices.com>
Tue, 9 Feb 2021 02:35:13 +0000 (21:35 -0500)
Only printing an empty line after the first target output is changed to
use the `enumerate` method on an Iterator with a non-zero index.

I could not get the `drop_println` macro to compile. Something about the
`shell` missing. The standard library `println` macro seems work fine.

src/cargo/ops/cargo_compile.rs

index 32ff02a7e07eac631131de78227349bbe33961ef..717c7cb95dad65ec02bbbb21171778dc212218c0 100644 (file)
@@ -308,14 +308,16 @@ pub fn print<'a>(
     if kinds.is_empty() {
         kinds.push(CompileKind::Host);
     }
-    let mut print_empty_line = false;
-    for kind in kinds {
+    for (index, kind) in kinds.iter().enumerate() {
+        if index != 0 {
+            println!();
+        }
         let rustflags = env_args(
             config,
             &build_config.requested_kinds,
             &rustc.host,
             None,
-            kind,
+            *kind,
             "RUSTFLAGS",
         )?;
         let mut process = rustc.process();
@@ -332,11 +334,6 @@ pub fn print<'a>(
         let output = process.exec_with_output()?;
         let stdout = std::io::stdout();
         let mut lock = stdout.lock();
-        if print_empty_line {
-            writeln!(lock)?;
-        } else {
-            print_empty_line = true;
-        }
         lock.write_all(&output.stdout)?;
         drop(lock);
     }