Skip to content

Commit

Permalink
test that we format the panic message only once
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Markeffsky committed Apr 25, 2023
1 parent a7aa205 commit cd398a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/ui/panics/fmt-only-once.rs
Original file line number Diff line number Diff line change
@@ -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:/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)
}
3 changes: 3 additions & 0 deletions tests/ui/panics/fmt-only-once.run.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cd398a6

Please sign in to comment.