Skip to content

Commit f96f443

Browse files
committed
Tweak how the extra newline is printed after coverage info
1 parent f095de4 commit f96f443

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler/rustc_middle/src/mir/pretty.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,15 @@ fn write_coverage_info_hi(
494494
mcdc_decision_spans,
495495
} = coverage_info_hi;
496496

497+
// Only add an extra trailing newline if we printed at least one thing.
498+
let mut did_print = false;
499+
497500
for coverage::BranchSpan { span, true_marker, false_marker } in branch_spans {
498501
writeln!(
499502
w,
500503
"{INDENT}coverage branch {{ true: {true_marker:?}, false: {false_marker:?} }} => {span:?}",
501504
)?;
505+
did_print = true;
502506
}
503507

504508
for coverage::MCDCBranchSpan {
@@ -514,6 +518,7 @@ fn write_coverage_info_hi(
514518
"{INDENT}coverage mcdc branch {{ condition_id: {:?}, true: {true_marker:?}, false: {false_marker:?}, depth: {decision_depth:?} }} => {span:?}",
515519
condition_info.map(|info| info.condition_id)
516520
)?;
521+
did_print = true;
517522
}
518523

519524
for coverage::MCDCDecisionSpan { span, num_conditions, end_markers, decision_depth } in
@@ -523,10 +528,10 @@ fn write_coverage_info_hi(
523528
w,
524529
"{INDENT}coverage mcdc decision {{ num_conditions: {num_conditions:?}, end: {end_markers:?}, depth: {decision_depth:?} }} => {span:?}"
525530
)?;
531+
did_print = true;
526532
}
527533

528-
if !branch_spans.is_empty() || !mcdc_branch_spans.is_empty() || !mcdc_decision_spans.is_empty()
529-
{
534+
if did_print {
530535
writeln!(w)?;
531536
}
532537

0 commit comments

Comments
 (0)