Skip to content

Commit 2e82a8d

Browse files
committed
Auto merge of #1304 - RalfJung:backtrace-sep, r=RalfJung
add empty line before backtrace, to separate it from help text I think this improves how things look, and makes it easier to see the help text (it currently kind of drowns next to the backtrace). Before: ``` error: unsupported operation: Miri does not support threading --> /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys/unix/thread.rs:68:19 | 68 | let ret = libc::pthread_create(&mut native, &attr, thread_start, &*p as *const _ as *mut _); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Miri does not support threading | = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support = note: inside `std::sys::unix::thread::Thread::new` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys/unix/thread.rs:68:19 = note: inside `std::thread::Builder::spawn_unchecked::<[closure@tests/compile-fail/thread-spawn.rs:6:19: 6:24], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/thread/mod.rs:492:26 = note: inside `std::thread::Builder::spawn::<[closure@tests/compile-fail/thread-spawn.rs:6:19: 6:24], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/thread/mod.rs:386:18 = note: inside `std::thread::spawn::<[closure@tests/compile-fail/thread-spawn.rs:6:19: 6:24], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/thread/mod.rs:619:5 note: inside `main` at tests/compile-fail/thread-spawn.rs:6:5 --> tests/compile-fail/thread-spawn.rs:6:5 | 6 | thread::spawn(|| {}); | ^^^^^^^^^^^^^^^^^^^^ = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:67:34 = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:52:73 = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<[closure@DefId(1:6030 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]::{{closure}}[0]) 0:&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys_common/backtrace.rs:130:5 = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:52:13 = note: inside `std::panicking::try::do_call::<[closure@DefId(1:6029 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/panicking.rs:331:40 = note: inside `std::panicking::try::<i32, [closure@DefId(1:6029 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe]>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/panicking.rs:274:15 = note: inside `std::panic::catch_unwind::<[closure@DefId(1:6029 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/panic.rs:394:14 = note: inside `std::rt::lang_start_internal` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:51:25 = note: inside `std::rt::lang_start::<()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:67:5 ``` After: ``` error: unsupported operation: Miri does not support threading --> /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys/unix/thread.rs:68:19 | 68 | let ret = libc::pthread_create(&mut native, &attr, thread_start, &*p as *const _ as *mut _); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Miri does not support threading | = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support = note: inside `std::sys::unix::thread::Thread::new` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys/unix/thread.rs:68:19 = note: inside `std::thread::Builder::spawn_unchecked::<[closure@tests/compile-fail/thread-spawn.rs:6:19: 6:24], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/thread/mod.rs:492:26 = note: inside `std::thread::Builder::spawn::<[closure@tests/compile-fail/thread-spawn.rs:6:19: 6:24], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/thread/mod.rs:386:18 = note: inside `std::thread::spawn::<[closure@tests/compile-fail/thread-spawn.rs:6:19: 6:24], ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/thread/mod.rs:619:5 note: inside `main` at tests/compile-fail/thread-spawn.rs:6:5 --> tests/compile-fail/thread-spawn.rs:6:5 | 6 | thread::spawn(|| {}); | ^^^^^^^^^^^^^^^^^^^^ = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:67:34 = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:52:73 = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<[closure@DefId(1:6030 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]::{{closure}}[0]) 0:&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys_common/backtrace.rs:130:5 = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:52:13 = note: inside `std::panicking::try::do_call::<[closure@DefId(1:6029 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/panicking.rs:331:40 = note: inside `std::panicking::try::<i32, [closure@DefId(1:6029 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe]>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/panicking.rs:274:15 = note: inside `std::panic::catch_unwind::<[closure@DefId(1:6029 ~ std[2f86]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/panic.rs:394:14 = note: inside `std::rt::lang_start_internal` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:51:25 = note: inside `std::rt::lang_start::<()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/rt.rs:67:5 ``` What do you think?
2 parents 910f874 + 95ea03c commit 2e82a8d

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/diagnostics.rs

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

107107
e.print_backtrace();
108108
let msg = e.to_string();
109-
report_msg(ecx, &format!("{}: {}", title, msg), msg, &helps, true)
109+
report_msg(ecx, &format!("{}: {}", title, msg), msg, helps, true)
110110
}
111111

112112
/// Report an error or note (depending on the `error` argument) at the current frame's current statement.
@@ -115,7 +115,7 @@ fn report_msg<'tcx, 'mir>(
115115
ecx: &InterpCx<'mir, 'tcx, Evaluator<'tcx>>,
116116
title: &str,
117117
span_msg: String,
118-
helps: &[String],
118+
mut helps: Vec<String>,
119119
error: bool,
120120
) -> Option<i64> {
121121
let span = if let Some(frame) = ecx.stack().last() {
@@ -129,8 +129,12 @@ fn report_msg<'tcx, 'mir>(
129129
ecx.tcx.sess.diagnostic().span_note_diag(span, title)
130130
};
131131
err.span_label(span, span_msg);
132-
for help in helps {
133-
err.help(help);
132+
if !helps.is_empty() {
133+
// Add visual separator before backtrace.
134+
helps.last_mut().unwrap().push_str("\n");
135+
for help in helps {
136+
err.help(&help);
137+
}
134138
}
135139
// Add backtrace
136140
let frames = ecx.generate_stacktrace();
@@ -182,7 +186,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
182186
CreatedAlloc(AllocId(id)) =>
183187
format!("created allocation with id {}", id),
184188
};
185-
report_msg(this, "tracking was triggered", msg, &[], false);
189+
report_msg(this, "tracking was triggered", msg, vec![], false);
186190
}
187191
});
188192
}

src/eval.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
186186
/// Returns `Some(return_code)` if program executed completed.
187187
/// Returns `None` if an evaluation error occured.
188188
pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) -> Option<i64> {
189-
// FIXME: on Windows, locks and TLS dtor management allocate and leave that memory in `static`s.
190-
// So we need https://github.com/rust-lang/miri/issues/940 to fix the leaks there.
189+
// FIXME: on Windows, we ignore leaks (https://github.com/rust-lang/miri/issues/1302).
191190
let ignore_leaks = config.ignore_leaks || tcx.sess.target.target.target_os == "windows";
192191

193192
let (mut ecx, ret_place) = match create_ecx(tcx, main_id, config) {

0 commit comments

Comments
 (0)