Change default panic handler message format.

This commit is contained in:
Mara Bos 2023-06-20 19:16:18 +02:00
parent 04411507be
commit 0e729404da
102 changed files with 231 additions and 128 deletions

View File

@ -93,7 +93,8 @@ information that is already communicated by the source error being
unwrapped:
```text
thread 'main' panicked at 'env variable `IMPORTANT_PATH` is not set: NotPresent', src/main.rs:4:6
thread 'main' panicked at src/main.rs:4:6:
env variable `IMPORTANT_PATH` is not set: NotPresent
```
In this example we end up mentioning that an env variable is not set,
@ -109,7 +110,8 @@ prevent the source error, we end up introducing new information that is
independent from our source error.
```text
thread 'main' panicked at 'env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`: NotPresent', src/main.rs:4:6
thread 'main' panicked at src/main.rs:4:6:
env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`: NotPresent
```
In this example we are communicating not only the name of the

View File

@ -147,16 +147,18 @@ impl<'a> PanicInfo<'a> {
impl fmt::Display for PanicInfo<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("panicked at ")?;
self.location.fmt(formatter)?;
if let Some(message) = self.message {
write!(formatter, "'{}', ", message)?
formatter.write_str(":\n")?;
formatter.write_fmt(*message)?;
} else if let Some(payload) = self.payload.downcast_ref::<&'static str>() {
write!(formatter, "'{}', ", payload)?
formatter.write_str(":\n")?;
formatter.write_str(payload)?;
}
// NOTE: we cannot use downcast_ref::<String>() here
// since String is not available in core!
// The payload is a String when `std::panic!` is called with multiple arguments,
// but in that case the message is also available.
self.location.fmt(formatter)
Ok(())
}
}

View File

@ -121,7 +121,8 @@ mod private {
/// This example produces the following output:
///
/// ```console
/// thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: SuperError is here!: SuperErrorSideKick is here!', src/error.rs:34:40
/// thread 'main' panicked at src/error.rs:34:40:
/// called `Result::unwrap()` on an `Err` value: SuperError is here!: SuperErrorSideKick is here!
/// note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
/// ```
///

View File

@ -266,7 +266,7 @@ pub fn panic_hook_with_disk_dump(info: &PanicInfo<'_>, path: Option<&crate::path
let name = thread.as_ref().and_then(|t| t.name()).unwrap_or("<unnamed>");
let write = |err: &mut dyn crate::io::Write, backtrace: Option<BacktraceStyle>| {
let _ = writeln!(err, "thread '{name}' panicked at '{msg}', {location}");
let _ = writeln!(err, "thread '{name}' panicked at {location}:\n{msg}");
static FIRST_PANIC: AtomicBool = AtomicBool::new(true);

View File

@ -1,4 +1,5 @@
thread '<unnamed>' panicked at 'explicit panic', $DIR/unwind_top_of_stack.rs:LL:CC
thread '<unnamed>' panicked at $DIR/unwind_top_of_stack.rs:LL:CC:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: Undefined Behavior: unwinding past the topmost frame of the stack
--> $DIR/unwind_top_of_stack.rs:LL:CC

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_bad_unwind1.rs:LL:CC
thread 'main' panicked at $DIR/exported_symbol_bad_unwind1.rs:LL:CC:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding
--> $DIR/exported_symbol_bad_unwind1.rs:LL:CC

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_bad_unwind2.rs:LL:CC
thread 'main' panicked at $DIR/exported_symbol_bad_unwind2.rs:LL:CC:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: abnormal termination: panic in a function that cannot unwind
--> $DIR/exported_symbol_bad_unwind2.rs:LL:CC

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_bad_unwind2.rs:LL:CC
thread 'main' panicked at $DIR/exported_symbol_bad_unwind2.rs:LL:CC:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: abnormal termination: panic in a function that cannot unwind
--> $DIR/exported_symbol_bad_unwind2.rs:LL:CC

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_bad_unwind2.rs:LL:CC
thread 'main' panicked at $DIR/exported_symbol_bad_unwind2.rs:LL:CC:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding
--> $DIR/exported_symbol_bad_unwind2.rs:LL:CC

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'explicit panic', $DIR/bad_unwind.rs:LL:CC
thread 'main' panicked at $DIR/bad_unwind.rs:LL:CC:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding
--> $DIR/bad_unwind.rs:LL:CC

View File

@ -1,6 +1,8 @@
thread 'main' panicked at 'first', $DIR/double_panic.rs:LL:CC
thread 'main' panicked at $DIR/double_panic.rs:LL:CC:
first
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'second', $DIR/double_panic.rs:LL:CC
thread 'main' panicked at $DIR/double_panic.rs:LL:CC:
second
stack backtrace:
error: abnormal termination: panic in a function that cannot unwind
--> $DIR/double_panic.rs:LL:CC

View File

@ -1,4 +1,5 @@
panicked at 'blarg I am dead', $DIR/no_std.rs:LL:CC
panicked at $DIR/no_std.rs:LL:CC:
blarg I am dead
error: abnormal termination: the program aborted execution
--> $DIR/no_std.rs:LL:CC
|

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'panicking from libstd', $DIR/panic_abort1.rs:LL:CC
thread 'main' panicked at $DIR/panic_abort1.rs:LL:CC:
panicking from libstd
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: abnormal termination: the program aborted execution
--> RUSTLIB/panic_abort/src/lib.rs:LL:CC

View File

@ -1,4 +1,5 @@
thread 'main' panicked at '42-panicking from libstd', $DIR/panic_abort2.rs:LL:CC
thread 'main' panicked at $DIR/panic_abort2.rs:LL:CC:
42-panicking from libstd
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: abnormal termination: the program aborted execution
--> RUSTLIB/panic_abort/src/lib.rs:LL:CC

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'panicking from libcore', $DIR/panic_abort3.rs:LL:CC
thread 'main' panicked at $DIR/panic_abort3.rs:LL:CC:
panicking from libcore
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: abnormal termination: the program aborted execution
--> RUSTLIB/panic_abort/src/lib.rs:LL:CC

View File

@ -1,4 +1,5 @@
thread 'main' panicked at '42-panicking from libcore', $DIR/panic_abort4.rs:LL:CC
thread 'main' panicked at $DIR/panic_abort4.rs:LL:CC:
42-panicking from libcore
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: abnormal termination: the program aborted execution
--> RUSTLIB/panic_abort/src/lib.rs:LL:CC

View File

@ -1,6 +1,7 @@
warning: You have explicitly enabled MIR optimizations, overriding Miri's default which is to completely disable them. Any optimizations may hide UB that Miri would otherwise detect, and it is not necessarily possible to predict what kind of UB will be missed. If you are enabling optimizations to make Miri run faster, we advise using cfg(miri) to shrink your workload instead. The performance benefit of enabling MIR optimizations is usually marginal at best.
thread 'main' panicked at 'explicit panic', $DIR/terminate-terminator.rs:LL:CC
thread 'main' panicked at $DIR/terminate-terminator.rs:LL:CC:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: abnormal termination: panic in a function that cannot unwind
--> $DIR/terminate-terminator.rs:LL:CC

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'explicit panic', $DIR/unwind-action-terminate.rs:LL:CC
thread 'main' panicked at $DIR/unwind-action-terminate.rs:LL:CC:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: abnormal termination: panic in a function that cannot unwind
--> $DIR/unwind-action-terminate.rs:LL:CC

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'attempt to divide by zero', $DIR/div-by-zero-2.rs:LL:CC
thread 'main' panicked at $DIR/div-by-zero-2.rs:LL:CC:
attempt to divide by zero
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,4 +1,7 @@
thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_good_unwind.rs:LL:CC
thread 'main' panicked at $DIR/exported_symbol_good_unwind.rs:LL:CC:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_good_unwind.rs:LL:CC
thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_good_unwind.rs:LL:CC
thread 'main' panicked at $DIR/exported_symbol_good_unwind.rs:LL:CC:
explicit panic
thread 'main' panicked at $DIR/exported_symbol_good_unwind.rs:LL:CC:
explicit panic

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'range end index 5 out of range for slice of length 4', $DIR/oob_subslice.rs:LL:CC
thread 'main' panicked at $DIR/oob_subslice.rs:LL:CC:
range end index 5 out of range for slice of length 4
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'attempt to shift left with overflow', $DIR/overflowing-lsh-neg.rs:LL:CC
thread 'main' panicked at $DIR/overflowing-lsh-neg.rs:LL:CC:
attempt to shift left with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-1.rs:LL:CC
thread 'main' panicked at $DIR/overflowing-rsh-1.rs:LL:CC:
attempt to shift right with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-2.rs:LL:CC
thread 'main' panicked at $DIR/overflowing-rsh-2.rs:LL:CC:
attempt to shift right with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'panicking from libstd', $DIR/panic1.rs:LL:CC
thread 'main' panicked at $DIR/panic1.rs:LL:CC:
panicking from libstd
stack backtrace:
0: std::panicking::begin_panic_handler
at RUSTLIB/std/src/panicking.rs:LL:CC

View File

@ -1,2 +1,3 @@
thread 'main' panicked at '42-panicking from libstd', $DIR/panic2.rs:LL:CC
thread 'main' panicked at $DIR/panic2.rs:LL:CC:
42-panicking from libstd
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'panicking from libcore', $DIR/panic3.rs:LL:CC
thread 'main' panicked at $DIR/panic3.rs:LL:CC:
panicking from libcore
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,2 +1,3 @@
thread 'main' panicked at '42-panicking from libcore', $DIR/panic4.rs:LL:CC
thread 'main' panicked at $DIR/panic4.rs:LL:CC:
42-panicking from libcore
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', $DIR/transmute_fat2.rs:LL:CC
thread 'main' panicked at $DIR/transmute_fat2.rs:LL:CC:
index out of bounds: the len is 0 but the index is 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'unsupported Miri functionality: can't call foreign function `foo` on $OS', $DIR/unsupported_foreign_function.rs:LL:CC
thread 'main' panicked at $DIR/unsupported_foreign_function.rs:LL:CC:
unsupported Miri functionality: can't call foreign function `foo` on $OS
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'unsupported Miri functionality: can't execute syscall with ID 0', $DIR/unsupported_syscall.rs:LL:CC
thread 'main' panicked at $DIR/unsupported_syscall.rs:LL:CC:
unsupported Miri functionality: can't execute syscall with ID 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,3 +1,5 @@
thread '<unnamed>' panicked at 'Hello!', $DIR/simple.rs:LL:CC
thread '<unnamed>' panicked at $DIR/simple.rs:LL:CC:
Hello!
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'childthread' panicked at 'Hello, world!', $DIR/simple.rs:LL:CC
thread 'childthread' panicked at $DIR/simple.rs:LL:CC:
Hello, world!

View File

@ -1,24 +1,35 @@
thread 'main' panicked at 'Hello from panic: std', $DIR/catch_panic.rs:LL:CC
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
Hello from panic: std
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Caught panic message (&str): Hello from panic: std
thread 'main' panicked at 'Hello from panic: 1', $DIR/catch_panic.rs:LL:CC
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
Hello from panic: 1
Caught panic message (String): Hello from panic: 1
thread 'main' panicked at 'Hello from panic: 2', $DIR/catch_panic.rs:LL:CC
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
Hello from panic: 2
Caught panic message (String): Hello from panic: 2
thread 'main' panicked at 'Box<dyn Any>', $DIR/catch_panic.rs:LL:CC
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
Box<dyn Any>
Failed to get caught panic message.
thread 'main' panicked at 'Hello from panic: core', $DIR/catch_panic.rs:LL:CC
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
Hello from panic: core
Caught panic message (&str): Hello from panic: core
thread 'main' panicked at 'Hello from panic: 5', $DIR/catch_panic.rs:LL:CC
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
Hello from panic: 5
Caught panic message (String): Hello from panic: 5
thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 4', $DIR/catch_panic.rs:LL:CC
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
index out of bounds: the len is 3 but the index is 4
Caught panic message (String): index out of bounds: the len is 3 but the index is 4
thread 'main' panicked at 'attempt to divide by zero', $DIR/catch_panic.rs:LL:CC
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
attempt to divide by zero
Caught panic message (&str): attempt to divide by zero
thread 'main' panicked at 'align_offset: align is not a power-of-two', RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
thread 'main' panicked at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC:
align_offset: align is not a power-of-two
Caught panic message (&str): align_offset: align is not a power-of-two
thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:LL:CC
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
assertion failed: false
Caught panic message (&str): assertion failed: false
thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:LL:CC
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
assertion failed: false
Caught panic message (&str): assertion failed: false
Success!

View File

@ -1,10 +1,12 @@
Thread 1 starting, will block on mutex
Thread 1 reported it has started
thread '<unnamed>' panicked at 'panic in thread 2', $DIR/concurrent-panic.rs:LL:CC
thread '<unnamed>' panicked at $DIR/concurrent-panic.rs:LL:CC:
panic in thread 2
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Thread 2 blocking on thread 1
Thread 2 reported it has started
Unlocking mutex
thread '<unnamed>' panicked at 'panic in thread 1', $DIR/concurrent-panic.rs:LL:CC
thread '<unnamed>' panicked at $DIR/concurrent-panic.rs:LL:CC:
panic in thread 1
Thread 1 has exited
Thread 2 has exited

View File

@ -1,4 +1,6 @@
thread 'main' panicked at 'once', $DIR/nested_panic_caught.rs:LL:CC
thread 'main' panicked at $DIR/nested_panic_caught.rs:LL:CC:
once
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'twice', $DIR/nested_panic_caught.rs:LL:CC
thread 'main' panicked at $DIR/nested_panic_caught.rs:LL:CC:
twice
stack backtrace:

View File

@ -2,7 +2,7 @@
{ "type": "test", "event": "started", "name": "a" }
{ "type": "test", "name": "a", "event": "ok" }
{ "type": "test", "event": "started", "name": "b" }
{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
{ "type": "test", "event": "started", "name": "c" }
{ "type": "test", "name": "c", "event": "ok" }
{ "type": "test", "event": "started", "name": "d" }

View File

@ -2,9 +2,9 @@
{ "type": "test", "event": "started", "name": "a" }
{ "type": "test", "name": "a", "event": "ok", "stdout": "print from successful test\n" }
{ "type": "test", "event": "started", "name": "b" }
{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
{ "type": "test", "event": "started", "name": "c" }
{ "type": "test", "name": "c", "event": "ok", "stdout": "thread 'c' panicked at 'assertion failed: false', f.rs:15:5\n" }
{ "type": "test", "name": "c", "event": "ok", "stdout": "thread 'c' panicked at f.rs:15:5:\nassertion failed: false\n" }
{ "type": "test", "event": "started", "name": "d" }
{ "type": "test", "name": "d", "event": "ignored", "message": "msg" }
{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME }

View File

@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"/><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>&#xA;<![CDATA[thread 'b' panicked at 'assertion failed: false', f.rs:10:5]]>&#xA;<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"/><system-out/><system-err/></testsuite></testsuites>
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"/><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>&#xA;<![CDATA[thread 'b' panicked at f.rs:10:5:]]>&#xA;<![CDATA[assertion failed: false]]>&#xA;<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"/><system-out/><system-err/></testsuite></testsuites>

View File

@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"><system-out><![CDATA[print from successful test]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>&#xA;<![CDATA[thread 'b' panicked at 'assertion failed: false', f.rs:10:5]]>&#xA;<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"><system-out><![CDATA[thread 'c' panicked at 'assertion failed: false', f.rs:16:5]]>&#xA;<![CDATA[]]></system-out></testcase><system-out/><system-err/></testsuite></testsuites>
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"><system-out><![CDATA[print from successful test]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>&#xA;<![CDATA[thread 'b' panicked at f.rs:10:5:]]>&#xA;<![CDATA[assertion failed: false]]>&#xA;<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"><system-out><![CDATA[thread 'c' panicked at f.rs:16:5:]]>&#xA;<![CDATA[assertion failed: false]]>&#xA;<![CDATA[]]></system-out></testcase><system-out/><system-err/></testsuite></testsuites>

View File

@ -26,7 +26,8 @@ stdout 2
stderr:
stderr 1
stderr 2
thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:7:1
thread 'main' panicked at $DIR/failed-doctest-output.rs:7:1:
oh no
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -4,7 +4,8 @@ error: expected one of `->`, `where`, or `{`, found `<eof>`
LL | fn wrong()
| ^ expected one of `->`, `where`, or `{`
thread panicked at 'aborting due to `-Z treat-err-as-bug`'
thread 'rustc' panicked at compiler/rustc_errors/src/lib.rs:1711:30:
aborting due to `-Z treat-err-as-bug=1`
stack backtrace:
error: the compiler unexpectedly panicked. this is a bug.

View File

@ -2,7 +2,8 @@
// be talking about `async fn`s instead.
// run-fail
// error-pattern: thread 'main' panicked at '`async fn` resumed after completion'
// error-pattern: thread 'main' panicked
// error-pattern: `async fn` resumed after completion
// edition:2018
// ignore-wasm no panic or subprocess support
// ignore-emscripten no panic or subprocess support

View File

@ -3,7 +3,8 @@
// run-fail
// needs-unwind
// error-pattern: thread 'main' panicked at '`async fn` resumed after panicking'
// error-pattern: thread 'main' panicked
// error-pattern: `async fn` resumed after panicking
// edition:2018
// ignore-wasm no panic or subprocess support

View File

@ -8,7 +8,7 @@
// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
// normalize-stderr-test "note: compiler flags.*\n\n" -> ""
// normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
// normalize-stderr-test "thread.*panicked.*\n" -> ""
// normalize-stderr-test "thread.*panicked.*:\n.*\n" -> ""
// normalize-stderr-test "stack backtrace:\n" -> ""
// normalize-stderr-test "\s\d{1,}: .*\n" -> ""
// normalize-stderr-test "\s at .*\n" -> ""

View File

@ -8,7 +8,7 @@
// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
// normalize-stderr-test "note: compiler flags.*\n\n" -> ""
// normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
// normalize-stderr-test "thread.*panicked.*\n" -> ""
// normalize-stderr-test "thread.*panicked.*:\n.*\n" -> ""
// normalize-stderr-test "stack backtrace:\n" -> ""
// normalize-stderr-test "\s\d{1,}: .*\n" -> ""
// normalize-stderr-test "\s at .*\n" -> ""

View File

@ -5,7 +5,7 @@
// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
// normalize-stderr-test "note: compiler flags.*\n\n" -> ""
// normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
// normalize-stderr-test "thread.*panicked.*\n" -> ""
// normalize-stderr-test "thread.*panicked.*:\n.*\n" -> ""
// normalize-stderr-test "stack backtrace:\n" -> ""
// normalize-stderr-test "\s\d{1,}: .*\n" -> ""
// normalize-stderr-test "\s at .*\n" -> ""

View File

@ -11,7 +11,7 @@
// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
// normalize-stderr-test "note: compiler flags.*\n\n" -> ""
// normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
// normalize-stderr-test "thread.*panicked.*\n" -> ""
// normalize-stderr-test "thread.*panicked.*:\n.*\n" -> ""
// normalize-stderr-test "stack backtrace:\n" -> ""
// normalize-stderr-test "\s\d{1,}: .*\n" -> ""
// normalize-stderr-test "\s at .*\n" -> ""

View File

@ -7,7 +7,7 @@
//[classic] build-fail
//[classic] failure-status: 101
//[classic] normalize-stderr-test "note: .*\n\n" -> ""
//[classic] normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
//[classic] normalize-stderr-test "thread 'rustc' panicked.*\n.*\n" -> ""
//[classic] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
//[classic] rustc-env:RUST_BACKTRACE=0

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:534:5
thread 'main' panicked at library/alloc/src/raw_vec.rs:534:5:
capacity overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -5,7 +5,7 @@
// error-pattern: aborting due to `-Z treat-err-as-bug=1`
// failure-status:101
// normalize-stderr-test ".*note: .*\n\n" -> ""
// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
// normalize-stderr-test "thread 'rustc' panicked.*:\n.*\n" -> ""
// rustc-env:RUST_BACKTRACE=0
use std::future::Future;

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'byte index 1 is out of bounds of ``', $DIR/const-eval-select-backtrace-std.rs:6:6
thread 'main' panicked at $DIR/const-eval-select-backtrace-std.rs:6:6:
byte index 1 is out of bounds of ``
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'Aaah!', $DIR/const-eval-select-backtrace.rs:17:9
thread 'main' panicked at $DIR/const-eval-select-backtrace.rs:17:9:
Aaah!
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,3 +1,5 @@
thread 'main' panicked at 'Here Once instance is poisoned.', $DIR/issue-87707.rs:14:24
thread 'main' panicked at $DIR/issue-87707.rs:14:24:
Here Once instance is poisoned.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'Once instance has previously been poisoned', $DIR/issue-87707.rs:16:7
thread 'main' panicked at $DIR/issue-87707.rs:16:7:
Once instance has previously been poisoned

View File

@ -1,3 +1,4 @@
257 > 255
error: the compiler unexpectedly panicked. this is a bug.
query stack during panic:

View File

@ -1,7 +1,7 @@
// run-fail
// error-pattern:panicked at 'assertion failed: `(left == right)`
// error-pattern:assertion failed: `(left == right)`
// error-pattern: left: `2`
// error-pattern:right: `3`: 1 + 1 definitely should be 3'
// error-pattern:right: `3`: 1 + 1 definitely should be 3
// ignore-emscripten no processes
fn main() {

View File

@ -1,5 +1,5 @@
// run-fail
// error-pattern:panicked at 'assertion failed: false'
// error-pattern:assertion failed: false
// ignore-emscripten no processes
fn main() {

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:panicked at 'test-assert-fmt 42 rust'
// error-pattern: panicked
// error-pattern: test-assert-fmt 42 rust
// ignore-emscripten no processes
fn main() {

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:panicked at 'test-assert-owned'
// error-pattern:panicked
// error-pattern:test-assert-owned
// ignore-emscripten no processes
#![allow(non_fmt_panics)]

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:panicked at 'test-assert-static'
// error-pattern:panicked
// error-pattern:test-assert-static
// ignore-emscripten no processes
fn main() {

View File

@ -1,7 +1,7 @@
// run-fail
// error-pattern:panicked at 'assertion failed: `(left matches right)`
// error-pattern:assertion failed: `(left matches right)`
// error-pattern: left: `2`
// error-pattern:right: `3`: 1 + 1 definitely should be 3'
// error-pattern:right: `3`: 1 + 1 definitely should be 3
// ignore-emscripten no processes
#![feature(assert_matches)]

View File

@ -1,7 +1,7 @@
// run-fail
// error-pattern:panicked at 'assertion failed: `(left != right)`
// error-pattern:assertion failed: `(left != right)`
// error-pattern: left: `2`
// error-pattern:right: `2`: 1 + 1 definitely should not be 2'
// error-pattern:right: `2`: 1 + 1 definitely should not be 2
// ignore-emscripten no processes
fn main() {

View File

@ -5,6 +5,7 @@ error: internal compiler error: broken MIR in Item(DefId(0:8 ~ storage_live[HASH
LL | StorageLive(a);
| ^^^^^^^^^^^^^^
aborting due to `-Z treat-err-as-bug=1`
error: the compiler unexpectedly panicked. this is a bug.
query stack during panic:

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern: thread 'main' panicked at 'explicit panic'
// error-pattern:thread 'main' panicked
// error-pattern:explicit panic
// ignore-emscripten no processes
fn main() {

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:thread 'main' panicked at 'attempt to add with overflow'
// error-pattern:thread 'main' panicked
// error-pattern:attempt to add with overflow
// compile-flags: -C debug-assertions
// ignore-emscripten no processes

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow'
// error-pattern:thread 'main' panicked
// error-pattern:attempt to multiply with overflow
// ignore-emscripten no processes
// compile-flags: -C debug-assertions

View File

@ -1,5 +1,5 @@
// run-fail
// error-pattern:thread 'main' panicked at 'attempt to negate with overflow'
// error-pattern:attempt to negate with overflow
// ignore-emscripten no processes
// compile-flags: -C debug-assertions

View File

@ -1,5 +1,5 @@
// run-fail
// error-pattern:thread 'main' panicked at 'attempt to negate with overflow'
// error-pattern:attempt to negate with overflow
// ignore-emscripten no processes
// compile-flags: -C debug-assertions

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow'
// error-pattern:thread 'main' panicked
// error-pattern:attempt to multiply with overflow
// ignore-emscripten no processes
// compile-flags: -C debug-assertions

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow'
// error-pattern:thread 'main' panicked
// error-pattern:attempt to multiply with overflow
// ignore-emscripten no processes
// compile-flags: -C debug-assertions

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:thread 'main' panicked at 'attempt to subtract with overflow'
// error-pattern:thread 'main' panicked
// error-pattern:attempt to subtract with overflow
// ignore-emscripten no processes
// compile-flags: -C debug-assertions

View File

@ -5,6 +5,7 @@ LL | fn main() { missing_ident; }
| ^^^^^^^^^^^^^ not found in this scope
aborting due to `-Z treat-err-as-bug=1`
stack backtrace:
(end_short_backtrace)
(begin_short_backtrace)

View File

@ -1,3 +1,4 @@
fmt
thread 'main' panicked at 'PrintOnFmt', $DIR/fmt-only-once.rs:20:5
thread 'main' panicked at $DIR/fmt-only-once.rs:20:5:
PrintOnFmt
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:23:5
thread 'main' panicked at $DIR/issue-47429-short-backtraces.rs:23:5:
explicit panic
stack backtrace:
0: std::panicking::begin_panic
1: issue_47429_short_backtraces::main

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:23:5
thread 'main' panicked at $DIR/issue-47429-short-backtraces.rs:23:5:
explicit panic
stack backtrace:
0: std::panicking::begin_panic::<&str>
1: issue_47429_short_backtraces::main

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'column-redacted', $DIR/location-detail-panic-no-column.rs:7:0
thread 'main' panicked at $DIR/location-detail-panic-no-column.rs:7:0:
column-redacted
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'file-redacted', <redacted>:7:5
thread 'main' panicked at <redacted>:7:5:
file-redacted
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'line-redacted', $DIR/location-detail-panic-no-line.rs:0:5
thread 'main' panicked at $DIR/location-detail-panic-no-line.rs:0:5:
line-redacted
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'no location info', <redacted>:0:0
thread 'main' panicked at <redacted>:0:0:
no location info
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,2 +1,3 @@
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', <redacted>:8:9
thread 'main' panicked at <redacted>:8:9:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:panicked at 'Box<dyn Any>'
// error-pattern:panicked
// error-pattern:Box<dyn Any>
// ignore-emscripten no processes
#![allow(non_fmt_panics)]

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:panicked at 'Box<dyn Any>'
// error-pattern:panicked
// error-pattern:Box<dyn Any>
// ignore-emscripten no processes
#![allow(non_fmt_panics)]

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:panicked at 'explicit panic'
// error-pattern:panicked
// error-pattern:explicit panic
// ignore-emscripten no processes
fn main() {

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:panicked at 'test-fail-fmt 42 rust'
// error-pattern:panicked
// error-pattern:test-fail-fmt 42 rust
// ignore-emscripten no processes
fn main() {

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:panicked at 'test-fail-owned'
// error-pattern:panicked
// error-pattern:test-fail-owned
// ignore-emscripten no processes
fn main() {

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:panicked at 'test-fail-static'
// error-pattern:panicked
// error-pattern:test-fail-static
// ignore-emscripten no processes
fn main() {

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:thread 'main' panicked at 'foobar'
// error-pattern:thread 'main' panicked
// error-pattern:foobar
// ignore-emscripten no processes
use std::panic;

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:thread 'main' panicked at 'foobar'
// error-pattern:thread 'main' panicked
// error-pattern:foobar
// ignore-emscripten no processes
use std::panic;

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:thread '<unnamed>' panicked at 'test'
// error-pattern:thread '<unnamed>' panicked
// error-pattern:test
// ignore-emscripten Needs threads
use std::thread;

View File

@ -1,5 +1,6 @@
// run-fail
// error-pattern:thread 'owned name' panicked at 'test'
// error-pattern:thread 'owned name' panicked
// error-pattern:test
// ignore-emscripten Needs threads.
use std::thread::Builder;

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'explicit panic', $DIR/runtime-switch.rs:26:5
thread 'main' panicked at $DIR/runtime-switch.rs:26:5:
explicit panic
stack backtrace:
0: std::panicking::begin_panic
1: runtime_switch::main

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'explicit panic', $DIR/runtime-switch.rs:26:5
thread 'main' panicked at $DIR/runtime-switch.rs:26:5:
explicit panic
stack backtrace:
0: std::panicking::begin_panic::<&str>
1: runtime_switch::main

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'debug!!!', $DIR/short-ice-remove-middle-frames-2.rs:56:5
thread 'main' panicked at $DIR/short-ice-remove-middle-frames-2.rs:56:5:
debug!!!
stack backtrace:
0: std::panicking::begin_panic
1: short_ice_remove_middle_frames_2::eight

View File

@ -1,4 +1,5 @@
thread 'main' panicked at 'debug!!!', $DIR/short-ice-remove-middle-frames.rs:52:5
thread 'main' panicked at $DIR/short-ice-remove-middle-frames.rs:52:5:
debug!!!
stack backtrace:
0: std::panicking::begin_panic
1: short_ice_remove_middle_frames::seven

View File

@ -1,4 +1,5 @@
at 'panic-derive', $DIR/auxiliary/test-macros.rs:43:5
at $DIR/auxiliary/test-macros.rs:43:5:
panic-derive
error: proc-macro derive panicked
--> $DIR/load-panic-backtrace.rs:11:10
|

View File

@ -8,10 +8,12 @@ fn check_for_no_backtrace(test: std::process::Output) {
let err = String::from_utf8_lossy(&test.stderr);
let mut it = err.lines();
assert_eq!(it.next().map(|l| l.starts_with("thread '<unnamed>' panicked at")), Some(true));
assert_eq!(it.next().map(|l| l.starts_with("thread '<unnamed>' panicked")), Some(true));
assert_eq!(it.next().is_some(), true);
assert_eq!(it.next(), Some("note: run with `RUST_BACKTRACE=1` \
environment variable to display a backtrace"));
assert_eq!(it.next().map(|l| l.starts_with("thread 'main' panicked at")), Some(true));
assert_eq!(it.next().is_some(), true);
assert_eq!(it.next(), None);
}

View File

@ -1,9 +1,11 @@
thread 'main' panicked at 'assertion failed: `(left == right)`
thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:33:5:
assertion failed: `(left == right)`
left: `2`,
right: `4`', $DIR/test-panic-abort-nocapture.rs:33:5
right: `4`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'assertion failed: `(left == right)`
thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:27:5:
assertion failed: `(left == right)`
left: `2`,
right: `4`', $DIR/test-panic-abort-nocapture.rs:27:5
right: `4`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
testing321

View File

@ -17,9 +17,10 @@ hello, world
testing123
---- it_fails stderr ----
testing321
thread 'main' panicked at 'assertion failed: `(left == right)`
thread 'main' panicked at $DIR/test-panic-abort.rs:38:5:
assertion failed: `(left == right)`
left: `2`,
right: `5`', $DIR/test-panic-abort.rs:38:5
right: `5`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -10,7 +10,8 @@ fee
fie
foe
fum
thread 'thready_fail' panicked at 'explicit panic', $DIR/test-thread-capture.rs:32:5
thread 'thready_fail' panicked at $DIR/test-thread-capture.rs:32:5:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -1,2 +1,3 @@
thread 'thready_fail' panicked at 'explicit panic', $DIR/test-thread-nocapture.rs:32:5
thread 'thready_fail' panicked at $DIR/test-thread-nocapture.rs:32:5:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

View File

@ -19,7 +19,7 @@ fn main() {
if args.len() == 1 {
let out = Command::new(&args[0]).arg("test").output().unwrap();
let stderr = std::str::from_utf8(&out.stderr).unwrap();
assert!(stderr.contains("panicked at 'explicit panic'"),
assert!(stderr.contains("explicit panic"),
"bad failure message:\n{}\n", stderr);
} else {
// TLS dtors are not always run on process exit

Some files were not shown because too many files have changed in this diff Show More