about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2024-07-05 13:07:30 +1000
committerZalathar <Zalathar@users.noreply.github.com>2024-07-05 13:53:05 +1000
commitf96f4436310d889da0ace73659f73500cc6c93c3 (patch)
treeb385406a2c8df96d5545f5eed8ae0eecaf0c7b48 /compiler/rustc_middle/src
parentf095de4bf105e92b035a7cd64c34bcce56b7cb78 (diff)
downloadrust-f96f4436310d889da0ace73659f73500cc6c93c3.tar.gz
rust-f96f4436310d889da0ace73659f73500cc6c93c3.zip
Tweak how the extra newline is printed after coverage info
Diffstat (limited to 'compiler/rustc_middle/src')
-rw-r--r--compiler/rustc_middle/src/mir/pretty.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs
index 5b2c603ce25..af19ed95193 100644
--- a/compiler/rustc_middle/src/mir/pretty.rs
+++ b/compiler/rustc_middle/src/mir/pretty.rs
@@ -494,11 +494,15 @@ fn write_coverage_info_hi(
         mcdc_decision_spans,
     } = coverage_info_hi;
 
+    // Only add an extra trailing newline if we printed at least one thing.
+    let mut did_print = false;
+
     for coverage::BranchSpan { span, true_marker, false_marker } in branch_spans {
         writeln!(
             w,
             "{INDENT}coverage branch {{ true: {true_marker:?}, false: {false_marker:?} }} => {span:?}",
         )?;
+        did_print = true;
     }
 
     for coverage::MCDCBranchSpan {
@@ -514,6 +518,7 @@ fn write_coverage_info_hi(
             "{INDENT}coverage mcdc branch {{ condition_id: {:?}, true: {true_marker:?}, false: {false_marker:?}, depth: {decision_depth:?} }} => {span:?}",
             condition_info.map(|info| info.condition_id)
         )?;
+        did_print = true;
     }
 
     for coverage::MCDCDecisionSpan { span, num_conditions, end_markers, decision_depth } in
@@ -523,10 +528,10 @@ fn write_coverage_info_hi(
             w,
             "{INDENT}coverage mcdc decision {{ num_conditions: {num_conditions:?}, end: {end_markers:?}, depth: {decision_depth:?} }} => {span:?}"
         )?;
+        did_print = true;
     }
 
-    if !branch_spans.is_empty() || !mcdc_branch_spans.is_empty() || !mcdc_decision_spans.is_empty()
-    {
+    if did_print {
         writeln!(w)?;
     }