test that we format the panic message only once

This commit is contained in:
Lukas Markeffsky 2023-04-23 15:24:34 +02:00
parent a7aa20517c
commit cd398a6de9
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,21 @@
// run-fail
// check-run-results
// exec-env:RUST_BACKTRACE=0
// Test that we format the panic message only once.
// Regression test for https://github.com/rust-lang/rust/issues/110717
use std::fmt;
struct PrintOnFmt;
impl fmt::Display for PrintOnFmt {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
eprintln!("fmt");
f.write_str("PrintOnFmt")
}
}
fn main() {
panic!("{}", PrintOnFmt)
}

View File

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