Skip to content

Commit 95ea03c

Browse files
committed
add empty line before backtrace, to separate it from help text
1 parent 0eccf1d commit 95ea03c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/diagnostics.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn report_error<'tcx, 'mir>(
102102

103103
e.print_backtrace();
104104
let msg = e.to_string();
105-
report_msg(ecx, &format!("{}: {}", title, msg), msg, &helps, true)
105+
report_msg(ecx, &format!("{}: {}", title, msg), msg, helps, true)
106106
}
107107

108108
/// Report an error or note (depending on the `error` argument) at the current frame's current statement.
@@ -111,7 +111,7 @@ fn report_msg<'tcx, 'mir>(
111111
ecx: &InterpCx<'mir, 'tcx, Evaluator<'tcx>>,
112112
title: &str,
113113
span_msg: String,
114-
helps: &[String],
114+
mut helps: Vec<String>,
115115
error: bool,
116116
) -> Option<i64> {
117117
let span = if let Some(frame) = ecx.stack().last() {
@@ -125,8 +125,12 @@ fn report_msg<'tcx, 'mir>(
125125
ecx.tcx.sess.diagnostic().span_note_diag(span, title)
126126
};
127127
err.span_label(span, span_msg);
128-
for help in helps {
129-
err.help(help);
128+
if !helps.is_empty() {
129+
// Add visual separator before backtrace.
130+
helps.last_mut().unwrap().push_str("\n");
131+
for help in helps {
132+
err.help(&help);
133+
}
130134
}
131135
// Add backtrace
132136
let frames = ecx.generate_stacktrace();
@@ -178,7 +182,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
178182
CreatedAlloc(AllocId(id)) =>
179183
format!("created allocation with id {}", id),
180184
};
181-
report_msg(this, "tracking was triggered", msg, &[], false);
185+
report_msg(this, "tracking was triggered", msg, vec![], false);
182186
}
183187
});
184188
}

0 commit comments

Comments
 (0)